You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/commandline/ps.md
+97-2Lines changed: 97 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,15 +51,110 @@ The currently supported filters are:
51
51
* exited (int - the code of exited containers. Only useful with `--all`)
52
52
* status (created|restarting|running|paused|exited)
53
53
54
-
## Successfully exited containers
54
+
55
+
#### Label
56
+
57
+
The `label` filter matches containers based on the presence of a `label` alone or a `label` and a
58
+
value.
59
+
60
+
The following filter matches containers with the `color` label regardless of its value.
61
+
62
+
$ docker ps --filter "label=color"
63
+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
64
+
673394ef1d4c busybox "top" 47 seconds ago Up 45 seconds nostalgic_shockley
65
+
d85756f57265 busybox "top" 52 seconds ago Up 51 seconds high_albattani
66
+
67
+
The following filter matches containers with the `color` label with the `blue` value.
68
+
69
+
$ docker ps --filter "label=color=blue"
70
+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
71
+
d85756f57265 busybox "top" About a minute ago Up About a minute high_albattani
72
+
73
+
#### Name
74
+
75
+
The `name` filter matches on all or part of a container's name.
76
+
77
+
The following filter matches all containers with a name containing the `nostalgic_stallman` string.
78
+
79
+
$ docker ps --filter "name=nostalgic_stallman"
80
+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
81
+
9b6247364a03 busybox "top" 2 minutes ago Up 2 minutes nostalgic_stallman
82
+
83
+
You can also filter for a substring in a name as this shows:
84
+
85
+
$ docker ps --filter "name=nostalgic"
86
+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
87
+
715ebfcee040 busybox "top" 3 seconds ago Up 1 seconds i_am_nostalgic
88
+
9b6247364a03 busybox "top" 7 minutes ago Up 7 minutes nostalgic_stallman
89
+
673394ef1d4c busybox "top" 38 minutes ago Up 38 minutes nostalgic_shockley
90
+
91
+
#### Exited
92
+
93
+
The `exited` filter matches containers by exist status code. For example, to filter for containers
94
+
that have exited successfully:
55
95
56
96
$ docker ps -a --filter 'exited=0'
57
97
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
58
98
ea09c3c82f6e registry:latest /srv/run.sh 2 weeks ago Exited (0) 2 weeks ago 127.0.0.1:5000->5000/tcp desperate_leakey
59
99
106ea823fe4e fedora:latest /bin/sh -c 'bash -l' 2 weeks ago Exited (0) 2 weeks ago determined_albattani
60
100
48ee228c9464 fedora:20 bash 2 weeks ago Exited (0) 2 weeks ago tender_torvalds
61
101
62
-
This shows all the containers that have exited with status of '0'
102
+
#### Status
103
+
104
+
The `status` filter matches containers by status. You can filter using `created`, `restarting`, `running`, `paused` and `exited`. For example, to filter for `running` containers:
105
+
106
+
$ docker ps --filter status=running
107
+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
108
+
715ebfcee040 busybox "top" 16 minutes ago Up 16 minutes i_am_nostalgic
109
+
d5c976d3c462 busybox "top" 23 minutes ago Up 23 minutes top
110
+
9b6247364a03 busybox "top" 24 minutes ago Up 24 minutes nostalgic_stallman
111
+
112
+
To filter for `paused` containers:
113
+
114
+
$ docker ps --filter status=paused
115
+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
116
+
673394ef1d4c busybox "top" About an hour ago Up About an hour (Paused) nostalgic_shockley
117
+
118
+
#### Ancestor
119
+
120
+
The `ancestor` filter matches containers based on its image or a descendant of it. The filter supports the
121
+
following image representation:
122
+
123
+
- image
124
+
- image:tag
125
+
- image:tag@digest
126
+
- short-id
127
+
- full-id
128
+
129
+
If you don't specify a `tag`, the `latest` tag is used. For example, to filter for containers that use the
130
+
latest `ubuntu` image:
131
+
132
+
$ docker ps --filter ancestor=ubuntu
133
+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
134
+
919e1179bdb8 ubuntu-c1 "top" About a minute ago Up About a minute admiring_lovelace
135
+
5d1e4a540723 ubuntu-c2 "top" About a minute ago Up About a minute admiring_sammet
136
+
82a598284012 ubuntu "top" 3 minutes ago Up 3 minutes sleepy_bose
137
+
bab2a34ba363 ubuntu "top" 3 minutes ago Up 3 minutes focused_yonath
138
+
139
+
Match containers based on the `ubuntu-c1` image which, in this case, is a child of `ubuntu`:
140
+
141
+
$ docker ps --filter ancestor=ubuntu-c1
142
+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
143
+
919e1179bdb8 ubuntu-c1 "top" About a minute ago Up About a minute admiring_lovelace
144
+
145
+
Match containers based on the `ubuntu` version `12.04.5` image:
146
+
147
+
$ docker ps --filter ancestor=ubuntu:12.04.5
148
+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
149
+
82a598284012 ubuntu:12.04.5 "top" 3 minutes ago Up 3 minutes sleepy_bose
150
+
151
+
The following matches containers based on the layer `d0e008c6cf02` or an image that have this layer
152
+
in it's layer stack.
153
+
154
+
$ docker ps --filter ancestor=d0e008c6cf02
155
+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
156
+
82a598284012 ubuntu:12.04.5 "top" 3 minutes ago Up 3 minutes sleepy_bose
0 commit comments