2015年6月28日 星期日

[ 常見問題 ] Get docker container name by PID

Source From Here 
Question 
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 ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
417af6d7dbfa 52366bfd2985:latest "sh /home/root/scrip 19 minutes ago Up 19 minutes 4444/tcp, 5999/tcp insane_ardinghelli

# docker inspect --format '{{.State.Pid}}' insane_ardinghelli
64998

Any idea how to get the name by PID ? 

How-To 
// -q, --quiet=false Only display numeric IDs
# docker ps -q
417af6d7dbfa
# docker ps -q | xargs docker inspect --format '{{.Name}}'
/insane_ardinghelli

Supplement 
Docker Doc - Using the command line 
"xargs" All-IN-One Tutorial Guide

沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...