Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 343
Nimrod007 Avatar asked Jun 25 '14 10:06

Nimrod007


Video Answer


1 Answers

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.

like image 172
ivant Avatar answered Oct 14 '22 21:10

ivant