I\'m using a Docker image which was built using the USER command to use a non-root user called dev.
Inside a container, I\'m \"dev\", but I want to edit the
I had exactly this problem of not being able to su to root because I was running in the container as an unprivileged user.
But I didn't want to rebuild a new image as the previous answers suggest.
Instead I have found that I could access the container as root using 'nsenter', see: https://github.com/jpetazzo/nsenter
First determine the PID of your container on the host:
docker inspect --format {{.State.Pid}}
Then use nsenter to enter the container as root
nsenter --target --mount --uts --ipc --net --pid