From 1a9819b613b307abb28cb11392478d06e68a69c4 Mon Sep 17 00:00:00 2001 From: David Calavera Date: Fri, 1 May 2015 14:23:27 -0700 Subject: [PATCH] Docker ps custom formatting. Docker-DCO-1.1-Signed-off-by: David Calavera --- man/docker-ps.1.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/man/docker-ps.1.md b/man/docker-ps.1.md index f60b5730..25032a47 100644 --- a/man/docker-ps.1.md +++ b/man/docker-ps.1.md @@ -16,6 +16,7 @@ docker-ps - List containers [**-q**|**--quiet**[=*false*]] [**-s**|**--size**[=*false*]] [**--since**[=*SINCE*]] +[**-F**|**--format**=*"TEMPLATE"*] # DESCRIPTION @@ -59,6 +60,20 @@ the running containers. **--since**="" Show only containers created since Id or Name, include non-running ones. +**-F**, **--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. + .Labels - All labels asigned to the container. + .Label - Value of a specific label for this container. For example `{{.Label "com.docker.swarm.cpu"}}` + # EXAMPLES # Display all containers, including non-running @@ -82,6 +97,32 @@ the running containers. # docker ps -a -q --filter=name=determined_torvalds c1d3b0166030 +# Display containers with their commands + + # docker ps --format "{{.ID}}: {{.Command}}" + a87ecb4f327c: /bin/sh -c #(nop) MA + 01946d9d34d8: /bin/sh -c #(nop) MA + c1d3b0166030: /bin/sh -c yum -y up + 41d50ecd2f57: /bin/sh -c #(nop) MA + +# Display containers with their labels in a table + + # docker ps --format "table {{.ID}}\t{{.Labels}}" + CONTAINER ID LABELS + a87ecb4f327c com.docker.swarm.node=ubuntu,com.docker.swarm.storage=ssd + 01946d9d34d8 + c1d3b0166030 com.docker.swarm.node=debian,com.docker.swarm.cpu=6 + 41d50ecd2f57 com.docker.swarm.node=fedora,com.docker.swarm.cpu=3,com.docker.swarm.storage=ssd + +# Display containers with their node label in a table + + # docker ps --format 'table {{.ID}}\t{{(.Label "com.docker.swarm.node")}}' + CONTAINER ID NODE + a87ecb4f327c ubuntu + 01946d9d34d8 + c1d3b0166030 debian + 41d50ecd2f57 fedora + # HISTORY April 2014, Originally compiled by William Henry (whenry at redhat dot com) based on docker.com source material and internal work.