CoreOS - get docker container name by PID?

Nimrod007 picture Nimrod007 · Jun 25, 2014 · Viewed 28.5k times · Source

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?

Answer

ivant picture ivant · Jun 25, 2014

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.