Aspnetcode 在 linux 中以非 root 用户运行

Dav*_*rra 5 asp.net-core

我正在尝试使用非 root 用户在 docker 映像(从 microsoft/aspnetcore 继承)中运行一个非常简单的 hello world aspnetcore 应用程序,但出现此错误:

暴击:Microsoft.AspNetCore.Server.Kestrel[0] 无法启动 Kestrel。System.AggregateException:发生一个或多个错误。(错误 -13 EACCES 权限被拒绝)---> Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvException:Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.ThrowError(Int32) 处拒绝错误 -13 EACCES 权限statusCode) at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.tcp_bind(UvTcpHandle handle, SockAddr& addr, Int32 flags) at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle.Bind(ServerAddress address) at Microsoft .AspNetCore.Server.Kestrel.Internal.Http.TcpListenerPrimary.CreateListenSocket() 在 Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Listener。

似乎没有 root 权限就无法运行 aspnetcore,并且在某些安全策略非常受限的场景中,root 用户是不允许运行 docker 镜像的主进程的。

有没有办法用非root用户在linux中运行aspnetcore应用程序?

由于相同的安全策略,Sudo 选项无效。

谢谢,

Dav*_*rra 4

最后的问题是我试图使用端口 80 来绑定我的应用程序。如果使用更高的端口,即5000。权限没有问题。

  • Linux 就是这样工作的。对于所有 <= 1024 的端口,您需要 root 才能绑定 (4认同)