Find the user who started a docker container
17,825
This worked for me:
docker inspect $(docker ps -aq) --format '{{.Config.User}} {{.Name}}'
My setup:
Host: Ubuntu 16.04
Docker version: 17.06.2-ce, build cec0b72
Related videos on Youtube
Author by
Oliver Dain
Updated on September 18, 2022Comments
-
Oliver Dain over 1 year
We've got many users who belong to the docker group. So any of these users can start a docker container.
docker ps
will show me all the running containers, but it doesn't show me which user started the container. The dockerd log also doesn't appear to indicate which user calldocker run
. Is there any way to find out what user started a given container? -
aleatha over 6 yearsThis will return the container user if it's explicitly set as part of the command line config when you ran the container (docker run --user ....), but not the user who ran the process.
-
Vicky Chijwani over 6 years@aleatha Thanks, this is still a useful answer in conjunction with your comment.
-
Trevor Boyd Smith over 2 yearsfor an explanation on why you can not see which user started the container see: stackoverflow.com/a/68505078/52074