Removed 'USER app' to fix issue with podman #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When running under podman, the server failed with "SocketException (13): Permission denied". The cause turned out to be the
USER app
in the Dockerfile:Under docker, ip_unprivileged_port_start in the container is 0 even if it's 1024 on the host:
This is why the server could bind to port 80 in the container despite running as a non-root user. (Apparently this was a change Docker made in 2020.)
Under podman, however, ip_unprivileged_port_start is the default 1024:
This is the case even if it's set to 0 on the host (either temporarily via sysctl or permanently by creating a file in /etc/sysctl.d), so the host's setting is basically irrelevant except for port binding host-side.
Which means that ironically, on the rootless engine, the container user needs to be root or it can't bind to port 80 (of course it's really the current user on the host that's being mapped to the root user in the container, but the container doesn't know that).
There are other ways to work around this, e.g. setting the NET_BIND_SERVICE capability, running the container with --sysctl, or changing the ports in the container to be >1024, but I'd rather keep the ports as they are and not need special flags to run in podman.
Set
--user app
when running the container to use the non-root user. Additionally,ASPNETCORE_HTTP_PORTS
can be set to override the container port if necessary (e.g.docker run -it --rm -v .:/srv:ro -p 3939:3939 --user app -e ASPNETCORE_HTTP_PORTS=3939 kagamine/sqlarserver
). I've modified the healthcheck to use this env var rather than assume port 80. The FTP server is still hardcoded to port 21, but if there's interest, we could add anFtpPort
(and a shorterPort
for HTTP) option to change that.