bash “docker ps”输出格式:仅列出正在运行的容器的名称
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50667371/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'docker ps' output formatting: list only names of running containers
提问by Paul Serikov
docker ps --format "table {{.Names}}"
output NAMES
in first row:
docker ps --format "table {{.Names}}"
NAMES
第一行输出:
root@docker-2gb-blr1-01:~# docker ps --format "table {{.Names}}"
NAMES
enr
osticket
osticket_db
...
docker inspect --format '{{.Name}}' $(docker ps -q)
docker inspect --format '{{.Name}}' $(docker ps -q)
prints /
in the beginning of container name:
/
在容器名称的开头打印:
root@docker-2gb-blr1-01:~# docker inspect --format '{{.Name}}' $(docker ps -q)"
/enr
/osticket
/osticket_db
I want to list only names of running containers, without header or slash in beginning. Please share options how to do this.
我只想列出正在运行的容器的名称,开头没有标题或斜线。请分享如何执行此操作的选项。
回答by whites11
Try removing the table
part from your --format
argument, such as:
尝试table
从您的--format
论点中删除该部分,例如:
docker ps --format '{{.Names}}'
It should give you a simple list of container names with no table heading
它应该给你一个简单的容器名称列表,没有表格标题