Nimrod007 Nimrod007 - 9 months ago 78
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}}'
{SOME DOCKER NAME}


any idea how to get the name by PID ?

thanks!

Answer Source

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.