diff options
| author | Misty Stanley-Jones <misty@apache.org> | 2017-04-03 16:54:34 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-04-03 16:54:34 -0700 |
| commit | 473c5701cb66403b0535a5c01845cb0f27fbeb47 (patch) | |
| tree | 9a40326ad4b426655abca7377dc30da003847d4d /docs/reference/commandline/ps.md | |
| parent | ce07fb6b0f1b8765b92022e45f96bd4349812e06 (diff) | |
| parent | 71e6babfa2598669218177b5b429e873b7f35e8f (diff) | |
| download | docker-1.13.x.tar.gz | |
Merge pull request #32332 from mstanleyjones/1.13.x1.13.x
Cherry-pick command-line ref improvements
Diffstat (limited to 'docs/reference/commandline/ps.md')
| -rw-r--r-- | docs/reference/commandline/ps.md | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/docs/reference/commandline/ps.md b/docs/reference/commandline/ps.md index 164e36433c..be88f9a307 100644 --- a/docs/reference/commandline/ps.md +++ b/docs/reference/commandline/ps.md @@ -35,7 +35,7 @@ Options: - name=<string> a container's name - network=(<network-id>|<network-name>) - since=(<container-name>|<container-id>) - - status=(created|restarting|removing|running|paused|exited) + - status=(created|restarting|removing|running|paused|exited) - volume=(<volume name>|<mount point destination>) --format string Pretty-print containers using a Go template --help Print usage @@ -46,6 +46,10 @@ Options: -s, --size Display total file sizes ``` +## Examples + +### Prevent truncating output + Running `docker ps --no-trunc` showing 2 linked containers. ```bash @@ -56,6 +60,8 @@ CONTAINER ID IMAGE COMMAND CREATED d7886598dbe2 crosbymichael/redis:latest /redis-server --dir 33 minutes ago Up 33 minutes 6379/tcp redis,webapp/db ``` +### Show both running and stopped containers + The `docker ps` command only shows running containers by default. To see all containers, use the `-a` (or `--all`) flag: @@ -67,7 +73,7 @@ $ docker ps -a container that exposes TCP ports `100, 101, 102` displays `100-102/tcp` in the `PORTS` column. -## Filtering +### Filtering The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there is more than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`) @@ -87,7 +93,7 @@ The currently supported filters are: * network (network id or name) - filters containers connected to the provided network * health (starting|healthy|unhealthy|none) - filters containers based on healthcheck status -#### Label +#### label The `label` filter matches containers based on the presence of a `label` alone or a `label` and a value. @@ -111,7 +117,7 @@ CONTAINER ID IMAGE COMMAND CREATED d85756f57265 busybox "top" About a minute ago Up About a minute high_albattani ``` -#### Name +#### name The `name` filter matches on all or part of a container's name. @@ -135,7 +141,7 @@ CONTAINER ID IMAGE COMMAND CREATED 673394ef1d4c busybox "top" 38 minutes ago Up 38 minutes nostalgic_shockley ``` -#### Exited +#### exited The `exited` filter matches containers by exist status code. For example, to filter for containers that have exited successfully: @@ -149,13 +155,14 @@ ea09c3c82f6e registry:latest /srv/run.sh 2 weeks ago 48ee228c9464 fedora:20 bash 2 weeks ago Exited (0) 2 weeks ago tender_torvalds ``` -#### Killed containers +#### Filter by exit signal You can use a filter to locate containers that exited with status of `137` meaning a `SIGKILL(9)` killed them. -```bash +```none $ docker ps -a --filter 'exited=137' + CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b3e1c0ed5bfe ubuntu:latest "sleep 1000" 12 seconds ago Exited (137) 5 seconds ago grave_kowalevski a2eb5558d669 redis:latest "/entrypoint.sh redi 2 hours ago Exited (137) 2 hours ago sharp_lalande @@ -167,7 +174,7 @@ Any of these events result in a `137` status: * `docker kill` kills the container * Docker daemon restarts which kills all running containers -#### Status +#### status The `status` filter matches containers by status. You can filter using `created`, `restarting`, `running`, `removing`, `paused`, `exited` and `dead`. For example, @@ -191,7 +198,7 @@ CONTAINER ID IMAGE COMMAND CREATED 673394ef1d4c busybox "top" About an hour ago Up About an hour (Paused) nostalgic_shockley ``` -#### Ancestor +#### ancestor The `ancestor` filter matches containers based on its image or a descendant of it. The filter supports the following image representation: @@ -244,7 +251,9 @@ CONTAINER ID IMAGE COMMAND CREATED 82a598284012 ubuntu:12.04.5 "top" 3 minutes ago Up 3 minutes sleepy_bose ``` -#### Before +#### Create time + +##### before The `before` filter shows only containers created before the container with given id or name. For example, having these containers created: @@ -268,7 +277,7 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS 6e63f6ff38b0 busybox "top" About a minute ago Up About a minute distracted_fermat ``` -#### Since +##### since The `since` filter shows only containers created since the container with given id or name. For example, with the same containers as in `before` filter: @@ -281,12 +290,12 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS 4aace5031105 busybox "top" 10 minutes ago Up 10 minutes focused_hamilton ``` -#### Volume +#### volume The `volume` filter shows only containers that mount a specific volume or have a volume mounted in a specific path: -```bash{% raw %} +```bash $ docker ps --filter volume=remote-volume --format "table {{.ID}}\t{{.Mounts}}" CONTAINER ID MOUNTS 9c3527ed70ce remote-volume @@ -294,9 +303,9 @@ CONTAINER ID MOUNTS $ docker ps --filter volume=/data --format "table {{.ID}}\t{{.Mounts}}" CONTAINER ID MOUNTS 9c3527ed70ce remote-volume -{% endraw %}``` +``` -#### Network +#### network The `network` filter shows only containers that are connected to a network with a given name or id. @@ -319,9 +328,7 @@ example shows all containers that are attached to the `net1` network, using the network id as a filter; ```bash -{% raw %} $ docker network inspect --format "{{.ID}}" net1 -{% endraw %} 8c0b4110ae930dbe26b258de9bc34a03f98056ed6f27f991d32919bfe401d7c5 @@ -331,7 +338,7 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS 9d4893ed80fe ubuntu "top" 10 minutes ago Up 10 minutes test1 ``` -## Formatting +### Formatting The formatting option (`--format`) pretty-prints container output using a Go template. @@ -350,7 +357,7 @@ Placeholder | Description `.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 `'{% raw %}{{.Label "com.docker.swarm.cpu"}}{% endraw %}'` +`.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. `.Networks` | Names of the networks attached to this container. @@ -362,9 +369,7 @@ The following example uses a template without headers and outputs the `ID` and `Command` entries separated by a colon for all running containers: ```bash -{% raw %} $ docker ps --format "{{.ID}}: {{.Command}}" -{% endraw %} a87ecb4f327c: /bin/sh -c #(nop) MA 01946d9d34d8: /bin/sh -c #(nop) MA @@ -375,9 +380,7 @@ c1d3b0166030: /bin/sh -c yum -y up To list all running containers with their labels in a table format you can use: ```bash -{% raw %} $ docker ps --format "table {{.ID}}\t{{.Labels}}" -{% endraw %} CONTAINER ID LABELS a87ecb4f327c com.docker.swarm.node=ubuntu,com.docker.swarm.storage=ssd |
