linuxbashdockercoreosnsenter

CoreOS - get docker container name by PID?


I have a list of PID's and I need to get their docker container name. Going the other direction is easy ... get PID of docker container by image name:

$ docker inspect --format '{{.State.Pid}}' {SOME DOCKER NAME}

Any idea how to get the name by PID?


Solution

  • Something like this?

    $ docker ps -q | xargs docker inspect --format '{{.State.Pid}}, {{.ID}}' | grep "^${PID},"
    

    [EDIT]

    Disclaimer This is for "normal" linux. I don't know anything useful about CoreOS, so this may or may not work there.