Docker Community Forums

Share and learn in the Docker community.

Manage docker as non-root user in docker-in-docker container

How do I build an image to manage docker as non-root user?

currently my Dockerfile roughly looks like this:

FROM docker:latest
RUN addgroup -S docker && adduser -S test -G docker
USER test:docker
CMD myapp

myapp is working normally if I use root user, but I want to be non-root user in certain scenario.

the document said your user need to be under docker group, so I create the group and add user into it.
but when I tried to execute docker command it still said permission denied. Some said you need to relogin and some said you need to restart docker daemon, is there any way to those in this container? or is there any workaround can solve this problem?

thanks for the help.

Well, I haven’t deployed Docker inside of Docker, and I haven’t attempted to run a container as non-root, so I might not be the most help there but… If you are asking how to restart the docker daemon, restarting the host would restart the Docker daemon that’s running the container running Docker (if I read that right). Otherwise I think “systemctrl restart docker” should work.