github.com/jiasir/docker@v1.3.3-0.20170609024000-252e610103e7/man/src/container/ls.md (about) 1 List the containers in the local repository. By default this shows only 2 the running containers. 3 4 ## Filters 5 6 Filter output based on these conditions: 7 - exited=<int> an exit code of <int> 8 - label=<key> or label=<key>=<value> 9 - status=(created|restarting|running|paused|exited|dead) 10 - name=<string> a container's name 11 - id=<ID> a container's ID 12 - is-task=(true|false) - containers that are a task (part of a service managed by swarm) 13 - before=(<container-name>|<container-id>) 14 - since=(<container-name>|<container-id>) 15 - ancestor=(<image-name>[:tag]|<image-id>|<image@digest>) - containers created from an image or a descendant. 16 - volume=(<volume-name>|<mount-point-destination>) 17 - network=(<network-name>|<network-id>) - containers connected to the provided network 18 - health=(starting|healthy|unhealthy|none) - filters containers based on healthcheck status 19 - publish=(<port>[/<proto>]|<startport-endport>/[<proto>]) - filters containers based on published ports 20 - expose=(<port>[/<proto>]|<startport-endport>/[<proto>]) - filters containers based on exposed ports 21 22 ## Format 23 24 Pretty-print containers using a Go template. 25 Valid placeholders: 26 .ID - Container ID 27 .Image - Image ID 28 .Command - Quoted command 29 .CreatedAt - Time when the container was created. 30 .RunningFor - Elapsed time since the container was started. 31 .Ports - Exposed ports. 32 .Status - Container status. 33 .Size - Container disk size. 34 .Names - Container names. 35 .Labels - All labels assigned to the container. 36 .Label - Value of a specific label for this container. For example `{{.Label "com.docker.swarm.cpu"}}` 37 .Mounts - Names of the volumes mounted in this container. 38 39 # EXAMPLES 40 ## Display all containers, including non-running 41 42 $ docker container ls -a 43 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 44 a87ecb4f327c fedora:20 /bin/sh -c #(nop) MA 20 minutes ago Exit 0 desperate_brattain 45 01946d9d34d8 vpavlin/rhel7:latest /bin/sh -c #(nop) MA 33 minutes ago Exit 0 thirsty_bell 46 c1d3b0166030 acffc0358b9e /bin/sh -c yum -y up 2 weeks ago Exit 1 determined_torvalds 47 41d50ecd2f57 fedora:20 /bin/sh -c #(nop) MA 2 weeks ago Exit 0 drunk_pike 48 49 ## Display only IDs of all containers, including non-running 50 51 $ docker container ls -a -q 52 a87ecb4f327c 53 01946d9d34d8 54 c1d3b0166030 55 41d50ecd2f57 56 57 ## Display only IDs of all containers that have the name `determined_torvalds` 58 59 $ docker container ls -a -q --filter=name=determined_torvalds 60 c1d3b0166030 61 62 ## Display containers with their commands 63 64 $ docker container ls --format "{{.ID}}: {{.Command}}" 65 a87ecb4f327c: /bin/sh -c #(nop) MA 66 01946d9d34d8: /bin/sh -c #(nop) MA 67 c1d3b0166030: /bin/sh -c yum -y up 68 41d50ecd2f57: /bin/sh -c #(nop) MA 69 70 ## Display containers with their labels in a table 71 72 $ docker container ls --format "table {{.ID}}\t{{.Labels}}" 73 CONTAINER ID LABELS 74 a87ecb4f327c com.docker.swarm.node=ubuntu,com.docker.swarm.storage=ssd 75 01946d9d34d8 76 c1d3b0166030 com.docker.swarm.node=debian,com.docker.swarm.cpu=6 77 41d50ecd2f57 com.docker.swarm.node=fedora,com.docker.swarm.cpu=3,com.docker.swarm.storage=ssd 78 79 ## Display containers with their node label in a table 80 81 $ docker container ls --format 'table {{.ID}}\t{{(.Label "com.docker.swarm.node")}}' 82 CONTAINER ID NODE 83 a87ecb4f327c ubuntu 84 01946d9d34d8 85 c1d3b0166030 debian 86 41d50ecd2f57 fedora 87 88 ## Display containers with `remote-volume` mounted 89 90 $ docker container ls --filter volume=remote-volume --format "table {{.ID}}\t{{.Mounts}}" 91 CONTAINER ID MOUNTS 92 9c3527ed70ce remote-volume 93 94 ## Display containers with a volume mounted in `/data` 95 96 $ docker container ls --filter volume=/data --format "table {{.ID}}\t{{.Mounts}}" 97 CONTAINER ID MOUNTS 98 9c3527ed70ce remote-volume 99 100 ## Display containers that have published port of 80: 101 102 $ docker ps --filter publish=80 103 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 104 fc7e477723b7 busybox "top" About a minute ago Up About a minute 0.0.0.0:32768->80/tcp admiring_roentgen 105 106 ## Display containers that have exposed TCP port in the range of `8000-8080`: 107 108 $ docker ps --filter expose=8000-8080/tcp 109 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 110 9833437217a5 busybox "top" 21 seconds ago Up 19 seconds 8080/tcp dreamy_mccarthy