Docker Community Forums

Share and learn in the Docker community.

Make "--user `whoami`" the default for "docker run"


(Harri) #1

Setting the --user myname on the docker run command line is painful and easy to forget. It would be very helpful if docker run could provide a default, e.g. set the USER attribute according to the current login name (whoami).


(David Maze) #2

Three notes:

(1) This would break essentially every prebuilt container, especially better-built ones that create their own private user ID in their Dockerfile.

(2) In the very common case of needing to run Docker as root (because remember, being able to run docker run at all implies root access to the host) you’d force containers to run as root, even if they were built for a less-privileged user.

(3) You will probably quickly find the number of command-line arguments to a typical docker run command becomes unmanageable (use -v to bind-mount persistent data and log directories; -p options to publish ports; and probably some -e environment variables and/or an extended command line) and you’ll want a shell script or Docker Compose file anyways, at which point it doesn’t matter what the defaults are.


(Harri) #3

OK, I misunderstood the documentation. My bad.

Problem is, how can I find the users who have run and forgot the billions of container zombies? What are your recommendations?