Nimrod007 Nimrod007 - 1 year ago 148
Linux Question

coreos - get docker container name by PID

i have 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}}'

any idea how to get the name by PID ?


Answer Source

Something like this?

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


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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download