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

Share:
17,825

Related videos on Youtube

Oliver Dain
Author by

Oliver Dain

Updated on September 18, 2022

Comments

  • Oliver Dain
    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 call docker run. Is there any way to find out what user started a given container?

  • aleatha
    aleatha over 6 years
    This 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
    Vicky Chijwani over 6 years
    @aleatha Thanks, this is still a useful answer in conjunction with your comment.
  • Trevor Boyd Smith
    Trevor Boyd Smith over 2 years
    for an explanation on why you can not see which user started the container see: stackoverflow.com/a/68505078/52074