Better security with unprivileged users
By default, containers execute everything as the root
user. Granted that containers are running in an isolated environment, but still, a publicly facing daemon is running as root on a system, and a security breach may give an attacker access to this particular container, and maybe root shell access, giving access at least to the container's Docker overlay network. Would we like to see this issue combined with a 0-day local kernel security breach that would give the attacker access to the Docker host? Probably not. Then, maybe we should keep some of the good old practices and start by executing our daemon as a user other than root.
Getting ready
To step through this recipe, you will need the following:
- A working Docker installation
- A sample HTTP server binary (sample code included)
How to do it…
Let's take a simple HTTP server that answers on the port 8000
of the container. Executed through a container, it would look like this, as seen earlier...