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:
placeholder | description< /th> |
---|---|
.ID | Container ID |
. Image | Image ID |
.Command | Quoted command |
.CreatedAt | Time when the container was created. |
.RunningFor | from the container Elapsed time since startup. (Elapsed time since the container was started.) |
.Ports | Exposed ports. |
.State | Container state. Container status (for example; “created”, “running”, “exited”). |
.Status | Container status, including information about duration and Details of the health status. Container status with details about duration and health-status. |
.Size | Container disk size. Container disk size. |
.Names | Container name. Container names. |
.Labels | All labels assigned to the container. All labels assigned to the container. |
.Label | The 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"}}' |
.Mounts td> | The name of the volume mounted in this container. Names of the volumes mounted in this container. |
.Networks | The names of the networks attached to this container. Names of the networks attached to this container. |
No Comment
Post your comment