【运维】docker ps 指定输出格式

本文介绍了如何临时使用`dockerps--format`参数来指定Docker容器查看的输出格式,包括展示ID、镜像、状态和名称等字段,以及如何通过编辑`~/.docker/config.json`来永久更改`ps`命令的默认输出格式。
摘要由CSDN通过智能技术生成

临时指定格式

docker ps --format "table {{.ID}}\\t{{.Image}}\\t{{.Status}}\\t{{.Names}}"

--format参数用于指定输出格式,说明如下:

  • table表示显示表头(属性名)
  • {{.ID}}等表示需要显示的属性
  • 属性之间可自定义分隔符,如\\t

可使用的属性名:

.ID - Container ID
.Image - Image ID
.Command - Quoted command
.CreatedAt - Time when the container was created.
.RunningFor - Elapsed time since the container was started.
.Ports - Exposed ports.
.Status - Container status.
.Size - Container disk size.
.Names - Container names.
.Labels - All labels assigned to the container.
.Label - Value of a specific label for this container. For example {{.Label "com.docker.swarm.cpu"}}
.Mounts - Names of the volumes mounted in this container.

永久更改格式

编辑~/.docker/config.json,添加"psFormat"

{
  "psFormat": "table {{.ID}}\\t{{.Image}}\\t{{.Status}}\\t{{.Names}}"
}
  • 8
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值