Docker Community Forums

Share and learn in the Docker community.

Docker run with nonroot user


(Nirajvara) #1

Hi

I want to run the docker via non-root user. I have see many docker hub images which directly login into the non-root user.

How I can also do the same.

I know the explicit command like -u= user to run docker with non-root user But I have without -u it should login into the non-root user.


(David Maze) #2

Their Dockerfiles have a USER statement. (And almost certainly run things like a bistro-specific adduser command to create the user they switch to.)

You could have a wrapper script that runs docker run with the correct options, or use a tool like Docker Compose. (And there are enough docker run options that you want frequently, that vary by container, that you probably should set this up anyways.)