Most of the Dockerfiles you find on the Internet build and run the software as root! That should scare everyone, right? ... but it doesn't seem like that ...
So pb is starting the server as root, even in the container, DANGEROUS, because the root inside the container is not at all different from the root outside the container.
One solution is to create the Dockerfile correctly using the USER statement, for example this example for a torque relay .
Another solution is to use the "linux username space" to "map" the UID / GID inside the container to the UID / GID outside the container. for example, root (uid = 0) inside the container can be mapped to your personal user account inside the host, so the files created on the shared volume have good permissions.
So my question is: what is the best practice when it comes to security with Docker? run code as non-root (for example, the USER statement in the Docker file)? Or using "username spaces"? Or eventually (or optionally) using selinux and / or AppArmor?
Thanks:)
source share