How to run node.js on port 80 inside Docker

Let's say I have this docker file .

What would be the best way to run it as a non-root user on port 80? (without adding a webserver in front)?

I tried to tweak this: How to run Node.js on port 80? But I'm out of luck, I think I don't understand how this works.

Do you think there is an elegant solution to this problem? I doubt it, but I hope ...

+3


source to share


1 answer


According to this site https://wiki.apache.org/httpd/NonRootPortBinding "setcap" sets the privilege to use port 80 at the kernel level. Containers run inside a namespace inside the host machine kernel. Therefore, your tutorials only work on virtual machines and dedicated servers. You may have more success running a docker container at a privileged level inside the host kernel:

$ docker run --privileged=true ...

      



Otherwise, you will have to refrain from using privileged ports (<1024). Typically, the Docker Way refrains from using privileged containers and relies solely on port mapping.

As per this ticket: https://github.com/docker/docker/issues/5650 setcap should normally work with docker containers, but fail if you are using the AUFS filesystem driver. This ticket is from 2014, so it can work with the latest version of AUFS.

+2


source







All Articles