Is there a way to start a rootless podman container with mapped privileged port (container service is exposed through host's port 1023 or lower)?
Running
$ podman run --rm -it -p 80:80 nginx:stable-alpine
Error: rootlessport cannot expose privileged port 80, you can add 'net.ipv4.ip_unprivileged_port_start=80' to /etc/sysctl.conf (currently 1024), or choose a larger port number (>= 1024): listen tcp 0.0.0.0:80: bind: permission denied
naturally fails because of insufficient permissions.
$ sudo capsh --caps=CAP_NET_BIND_SERVICE+eip -- -c 'podman run --rm -it -p 80:80 nginx:stable-alpine'
runs podman as a root user
$ sudo capsh --caps=CAP_NET_BIND_SERVICE+eip --user=$USER -- -c 'podman run --rm -it -p 80:80 nginx:stable-alpine'
Unable to set group list for user: Operation not permitted
fails because of su permissions.
So far I ended up with a sub-optimal solution that temporarily allows any process to bind a privileged port for couple of seconds:
sudo sysctl net.ipv4.ip_unprivileged_port_start=80 ;\
( sleep 5 ; sudo sysctl net.ipv4.ip_unprivileged_port_start=1024 ) &\
podman run --rm -it -p 80:80 nginx:stable-alpine