by Devin Yang
(This article was automatically translated.)

Published - 2 years ago ( Updated - 2 years ago )

I think if you want to write some automation functions, it may be useful to be able to format the output container content.
The following are some reference examples of Docker container formatting and display commands

docker ps --format "{{.ID}}\t{{.Names} }"
#For example, the name and command to execute
docker ps --format "table {{.Names}}: {{.Command}}" --no-trunc
#If there is a table, it will contain the field name
docker ps --filter volume=/data --format "table {{.ID}}\t{{.Mounts}}" --no-trunc
#If Docker swarm mode can also be used
docker service ls --format "table {{.Name}}\t{{.Ports}}"

Format

Format option (--format ) to pretty print container output using Go templates.
The valid placeholders for Go templates are listed below:

placeholderdescription< /th>
.IDContainer ID
. ImageImage ID
.CommandQuoted command
.CreatedAtTime when the container was created.
.RunningFor from the container Elapsed time since startup. (Elapsed time since the container was started.)
.PortsExposed ports.
.StateContainer state. Container status (for example; “created”, “running”, “exited”).
.StatusContainer status, including information about duration and Details of the health status. Container status with details about duration and health-status.
.SizeContainer disk size. Container disk size.
.NamesContainer name. Container names.
.LabelsAll labels assigned to the container. All labels assigned to the container.
.LabelThe value of a specific label for this container. For example '{{.Label "com.docker.swarm.cpu"}}'.
Value of a specific label for this container. For example '{{.Label "com.docker.swarm.cpu"}}'
.MountsThe name of the volume mounted in this container. Names of the volumes mounted in this container.
.NetworksThe names of the networks attached to this container. Names of the networks attached to this container.

Tags: docker cli

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments

Similar Stories


docker

Storage and retrieval of Docker image

How to archive the docker image into a tar file and load back the docker image. We can use docker save and docker load.

docker,polymer,seo

Solving Polymer SEO Problems with Rendertron (Polymer Summit 2017)

The video below the article introduces how to use rendertron to solve Polymer SEO optimization problems. In the source of my fork, it has been adjusted to support the Chinese environment. And also added the API interface of pdf, which can also be used to convert pdf.

docker

Where is the volume location of Docker?

we can use docker volume ls List all dossiers. When using inspect on OSx to view, as a result, we can't find the Mountpoint directory when we get to the Mac?