如何排序或排序结果docker ps --format?
使用时,我找不到任何排序结果的方法 docker ps
就我而言,我想按.Ports订购
docker ps -a --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}"
如何订购结果?
回答:
格式化和订购 docker ps
docker ps
docker ps -a --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}" | (read -r; printf "%s\n" "$REPLY"; sort -k 3 )
docker ps [--format="TEMPLATE"]--format="TEMPLATE"
Pretty-print containers using a Go template.
Valid placeholders:
.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 ps --format "{{.ID}}: {{.Command}}"
docker ps --format "table {{.ID}}\t{{.Labels}}"
docker ps --format 'table {{.ID}}\t{{(.Label "com.docker.swarm.node")}}'
以上是 如何排序或排序结果docker ps --format? 的全部内容, 来源链接: utcz.com/qa/433191.html