Privileges in an Ubuntu Docker container after USER statement in Dockerfile
docker, dockerfile, root, ubuntu
Solution
If you don't want to use sudo, you could have a Dockerfile without `USER` (so it runs the command as root) and `CMD` pointing to a script that does the user switching, that way a `docker exec` would run as root.
Other way is to set the root password and use `su`. An example of doing that is in the tutum images
https://github.com/tutumcloud/tutum-centos/blob/master/set_root_pw.sh
Problem
I created a Dockerfile ``` FROM ubuntu:latest ``` as the parent image. Later the Dockerfile creates a new group and user without sudo privileges via ``` RUN groupadd -r myappuser -g 433 RUN useradd -u 431 -r -g myappuser -d /opt/myapp -s /bin/false -c "my app user" myappuser ``` Before executing the application I switch to this new ``` USER myappuser ``` Question: Does this setting make it possible to gain root privileges again once the image is build and the container is running (with e.g. `docker exec -it`)?