Let's say I have this Dockerfile.
What would be the best way to run it as non privileged user on port 80? (without adding a webserver in front)?
I tried to set up this: How do I run Node.js on port 80? But I wasn't lucky, I think I don't understand deeply how this work.
Do you think there is an elegant solution to solve this issue? I'm doubtful, but hopeful :)
The default port for HTTP is 80 – Generally, most web browsers listen to the default port. Below is the code implementation for creating a server in node and making it listen to port 80.
Port mapping makes the processes inside the container available from the outside. The above command launches an httpd container and maps the host's port 81 to port 80 inside that container. By default, the httpd server listens on port 80. It's not mandatory to perform port mapping for all Docker containers.
To publish a port for our container, we'll use the --publish flag ( -p for short) on the docker run command. The format of the --publish command is [host port]:[container port] . So, if we wanted to expose port 8000 inside the container to port 8080 outside the container, we would pass 8080:8000 to the --publish flag.
According to this site https://wiki.apache.org/httpd/NonRootPortBinding "setcap" sets the privilege to use Port 80 on kernel level. Containers run inside a namespace inside the hosts machine kernel. So your tutorials only work on Virtual Machines and Dedicated servers. You may have more success with running your docker container on privileged level inside the host kernel:
$ docker run --privileged=true ...
Otherwise you will have to refrain yourself from using privileged ports (< 1024). The "Docker Way" is usually to refrain from using privileged containers and solely rely on port mapping.
According to this Ticket: https://github.com/docker/docker/issues/5650 setcap should generally work with docker containers but will fail, if you use the AUFS filesystem driver. This ticket is from 2014 so this may work with the latest AUFS implementation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With