I'm running a container as non-root (see Dockerfile below), and am a bit confused to why it's successfully binding to port 80. I'd expect this to not have permission to bind to anything below 1024. This is running locally on Docker for Windows (which uses WSL2).
Any ideas?
FROM mcr.microsoft.com/dotnet/aspnet:7.0
EXPOSE 80
WORKDIR /app
...usual COPY stuff...
# Change user to non-root (gecos means don't interactively prompt for various info about the user)
RUN adduser --disabled-password --gecos '' appuser
USER appuser
ENTRYPOINT ["dotnet", "MyWebApi.dll"]
docker run --rm -p 80:80 myimage
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://[::]:80
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: /app
Running this against the containers shows it is running as that nonroot user...
docker exec <containerid> id
Output:
uid=1000(appuser) gid=1000(appuser) groups=1000(appuser)