docker - 在Bash中检查Docker实例

标签 docker awk

docker ps -a我想匹配NAMES VERSIONSTATUS

docker ps -a --format "{{.Image}}\t{{.Status}}" | awk -F$"\t" '{printf "%s|%s\n", $1, $2}'
输出:
registry.com/project/glass/glass_front:2.2.15.4|Up 6 days
registry.com/project/glass/glass_proxy:2.2.15.4|Up 6 days
registry.com/project/glass/glass_modeles_front:2.1.5.2|Up 6 days
我如何修改我的命令以具有此功能:
glass_front | 2.2.15.4 | Up 6 days
glass_proxy | 2.2.15.4 | Up 6 days
glass_modeles_front| 2.1.5.2 | Up 6 days

最佳答案

尝试在docker ps命令中使用冒号作为分隔符,然后使用sed将冒号转换为管道并删除前缀:

docker ps -a --format "{{.Image}}:{{.Status}}" \
| sed -e 's/:/ | /g' -e 's,^.*/,,'

关于docker - 在Bash中检查Docker实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64157074/

相关文章:

docker - 在 centos 7 dockerfile 中安装 java 8

docker - 如何在带有Mono的Docker容器中安装MS Office?

awk - 如何在执行 awk 时不删除 header

sed - 将匹配的行复制到第二个文件

regex - 已编辑 : Grep/Awk- Print specific info from table

带有 Lustre 的 Docker Swarm 卷?

docker 启动 apache 和 neo4j 后立即退出

docker - 从本地(未发布)镜像构建 docker 镜像

regex - 使用 grep 查找动态文本

shell - awk 在 shell 中打印数组的一部分