This is a strange problem that I cannot figure out
My user outside the container is in the docker groups, when I mount passwd/group/sudoers etc into the container, and directly launch my host uid/gid into the container, I am not part of the docker group.
I don’t understand why you bind-mount all these directories … doesn’t make much sense …
On top you try to execute a “docker ps” tailed to the “docker run …” command … which should fail (except your contaier itself is also running docker ). This command will list all running containers not processes and certainly not any user credentials
The second line will lauch a container, execute a sudo, pop up a bash and die instantly afterwards …
It’s not a good idea anyway to use any host credentials directly inside a container. A container is ment run autonomous from its host (more or less)
Please explain what you’re try to achive ? Why do you need all these files inside the container ?
There are two reasons why I am mounting those directories.
One:
I’m sharing my user credentials with the container to access the X server to run a gui based app, and running as a non-root user in the container. See the following link for motivation:
Two
I am not trying to run “docker within docker”, but rather allow the container access to the host docker daemon, to allow a container to start a second container on the host (not within the container). See the following link:
Should allow running the host uid/gid within the container, and therefore having access to the docker daemon (which it does in the second example above that I posted).
The developer can set a default user to run the first process with the Dockerfile USER instruction. When starting a container, the operator can override the USER instruction by passing the -u option.
The Dockerfile of the ubuntu image(s) does not declare a USER, as such the -u option has no effect.