CoreOS - get docker container name by PID?

后端 未结 3 1915
孤独总比滥情好
孤独总比滥情好 2020-12-30 03:28

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:

$ doc         


        
3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-30 04:08

    Because @Mitar's comment suggestion deserves to be a full answer:

    To get container ID you can use:

    cat /proc//cgroup
    

    Then to convert the container ID to docker container name:

    docker inspect --format '{{.Name}}' "${containerId}" | sed 's/^\///'
    

提交回复
热议问题