github.com/fabiokung/docker@v0.11.2-0.20170222101415-4534dcd49497/docs/reference/commandline/images.md (about) 1 --- 2 title: "images" 3 description: "The images command description and usage" 4 keywords: "list, docker, images" 5 --- 6 7 <!-- This file is maintained within the docker/docker Github 8 repository at https://github.com/docker/docker/. Make all 9 pull requests against that repo. If you see this file in 10 another repository, consider it read-only there, as it will 11 periodically be overwritten by the definitive file. Pull 12 requests which include edits to this file in other repositories 13 will be rejected. 14 --> 15 16 # images 17 18 ```markdown 19 Usage: docker images [OPTIONS] [REPOSITORY[:TAG]] 20 21 List images 22 23 Options: 24 -a, --all Show all images (default hides intermediate images) 25 --digests Show digests 26 -f, --filter value Filter output based on conditions provided (default []) 27 - dangling=(true|false) 28 - label=<key> or label=<key>=<value> 29 - before=(<image-name>[:tag]|<image-id>|<image@digest>) 30 - since=(<image-name>[:tag]|<image-id>|<image@digest>) 31 - reference=(pattern of an image reference) 32 --format string Pretty-print images using a Go template 33 --help Print usage 34 --no-trunc Don't truncate output 35 -q, --quiet Only show numeric IDs 36 ``` 37 38 ## Description 39 40 The default `docker images` will show all top level 41 images, their repository and tags, and their size. 42 43 Docker images have intermediate layers that increase reusability, 44 decrease disk usage, and speed up `docker build` by 45 allowing each step to be cached. These intermediate layers are not shown 46 by default. 47 48 The `SIZE` is the cumulative space taken up by the image and all 49 its parent images. This is also the disk space used by the contents of the 50 Tar file created when you `docker save` an image. 51 52 An image will be listed more than once if it has multiple repository names 53 or tags. This single image (identifiable by its matching `IMAGE ID`) 54 uses up the `SIZE` listed only once. 55 56 ## Examples 57 58 ### List the most recently created images 59 60 ```bash 61 $ docker images 62 63 REPOSITORY TAG IMAGE ID CREATED SIZE 64 <none> <none> 77af4d6b9913 19 hours ago 1.089 GB 65 committ latest b6fa739cedf5 19 hours ago 1.089 GB 66 <none> <none> 78a85c484f71 19 hours ago 1.089 GB 67 docker latest 30557a29d5ab 20 hours ago 1.089 GB 68 <none> <none> 5ed6274db6ce 24 hours ago 1.089 GB 69 postgres 9 746b819f315e 4 days ago 213.4 MB 70 postgres 9.3 746b819f315e 4 days ago 213.4 MB 71 postgres 9.3.5 746b819f315e 4 days ago 213.4 MB 72 postgres latest 746b819f315e 4 days ago 213.4 MB 73 ``` 74 75 ### List images by name and tag 76 77 The `docker images` command takes an optional `[REPOSITORY[:TAG]]` argument 78 that restricts the list to images that match the argument. If you specify 79 `REPOSITORY`but no `TAG`, the `docker images` command lists all images in the 80 given repository. 81 82 For example, to list all images in the "java" repository, run this command : 83 84 ```bash 85 $ docker images java 86 87 REPOSITORY TAG IMAGE ID CREATED SIZE 88 java 8 308e519aac60 6 days ago 824.5 MB 89 java 7 493d82594c15 3 months ago 656.3 MB 90 java latest 2711b1d6f3aa 5 months ago 603.9 MB 91 ``` 92 93 The `[REPOSITORY[:TAG]]` value must be an "exact match". This means that, for example, 94 `docker images jav` does not match the image `java`. 95 96 If both `REPOSITORY` and `TAG` are provided, only images matching that 97 repository and tag are listed. To find all local images in the "java" 98 repository with tag "8" you can use: 99 100 ```bash 101 $ docker images java:8 102 103 REPOSITORY TAG IMAGE ID CREATED SIZE 104 java 8 308e519aac60 6 days ago 824.5 MB 105 ``` 106 107 If nothing matches `REPOSITORY[:TAG]`, the list is empty. 108 109 ```bash 110 $ docker images java:0 111 112 REPOSITORY TAG IMAGE ID CREATED SIZE 113 ``` 114 115 ### List the full length image IDs 116 117 ```bash 118 $ docker images --no-trunc 119 120 REPOSITORY TAG IMAGE ID CREATED SIZE 121 <none> <none> sha256:77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182 19 hours ago 1.089 GB 122 committest latest sha256:b6fa739cedf5ea12a620a439402b6004d057da800f91c7524b5086a5e4749c9f 19 hours ago 1.089 GB 123 <none> <none> sha256:78a85c484f71509adeaace20e72e941f6bdd2b25b4c75da8693efd9f61a37921 19 hours ago 1.089 GB 124 docker latest sha256:30557a29d5abc51e5f1d5b472e79b7e296f595abcf19fe6b9199dbbc809c6ff4 20 hours ago 1.089 GB 125 <none> <none> sha256:0124422dd9f9cf7ef15c0617cda3931ee68346455441d66ab8bdc5b05e9fdce5 20 hours ago 1.089 GB 126 <none> <none> sha256:18ad6fad340262ac2a636efd98a6d1f0ea775ae3d45240d3418466495a19a81b 22 hours ago 1.082 GB 127 <none> <none> sha256:f9f1e26352f0a3ba6a0ff68167559f64f3e21ff7ada60366e2d44a04befd1d3a 23 hours ago 1.089 GB 128 tryout latest sha256:2629d1fa0b81b222fca63371ca16cbf6a0772d07759ff80e8d1369b926940074 23 hours ago 131.5 MB 129 <none> <none> sha256:5ed6274db6ceb2397844896966ea239290555e74ef307030ebb01ff91b1914df 24 hours ago 1.089 GB 130 ``` 131 132 ### List image digests 133 134 Images that use the v2 or later format have a content-addressable identifier 135 called a `digest`. As long as the input used to generate the image is 136 unchanged, the digest value is predictable. To list image digest values, use 137 the `--digests` flag: 138 139 ```bash 140 $ docker images --digests 141 REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE 142 localhost:5000/test/busybox <none> sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf 4986bf8c1536 9 weeks ago 2.43 MB 143 ``` 144 145 When pushing or pulling to a 2.0 registry, the `push` or `pull` command 146 output includes the image digest. You can `pull` using a digest value. You can 147 also reference by digest in `create`, `run`, and `rmi` commands, as well as the 148 `FROM` image reference in a Dockerfile. 149 150 ### Filtering 151 152 The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more 153 than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`) 154 155 The currently supported filters are: 156 157 * dangling (boolean - true or false) 158 * label (`label=<key>` or `label=<key>=<value>`) 159 * before (`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`) - filter images created before given id or references 160 * since (`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`) - filter images created since given id or references 161 162 #### Show untagged images (dangling) 163 164 ```bash 165 $ docker images --filter "dangling=true" 166 167 REPOSITORY TAG IMAGE ID CREATED SIZE 168 <none> <none> 8abc22fbb042 4 weeks ago 0 B 169 <none> <none> 48e5f45168b9 4 weeks ago 2.489 MB 170 <none> <none> bf747efa0e2f 4 weeks ago 0 B 171 <none> <none> 980fe10e5736 12 weeks ago 101.4 MB 172 <none> <none> dea752e4e117 12 weeks ago 101.4 MB 173 <none> <none> 511136ea3c5a 8 months ago 0 B 174 ``` 175 176 This will display untagged images that are the leaves of the images tree (not 177 intermediary layers). These images occur when a new build of an image takes the 178 `repo:tag` away from the image ID, leaving it as `<none>:<none>` or untagged. 179 A warning will be issued if trying to remove an image when a container is presently 180 using it. By having this flag it allows for batch cleanup. 181 182 You can use this in conjunction with `docker rmi ...`: 183 184 ```bash 185 $ docker rmi $(docker images -f "dangling=true" -q) 186 187 8abc22fbb042 188 48e5f45168b9 189 bf747efa0e2f 190 980fe10e5736 191 dea752e4e117 192 511136ea3c5a 193 ``` 194 195 > **Note**: Docker warns you if any containers exist that are using these 196 > untagged images. 197 198 199 #### Show images with a given label 200 201 The `label` filter matches images based on the presence of a `label` alone or a `label` and a 202 value. 203 204 The following filter matches images with the `com.example.version` label regardless of its value. 205 206 ```bash 207 $ docker images --filter "label=com.example.version" 208 209 REPOSITORY TAG IMAGE ID CREATED SIZE 210 match-me-1 latest eeae25ada2aa About a minute ago 188.3 MB 211 match-me-2 latest dea752e4e117 About a minute ago 188.3 MB 212 ``` 213 214 The following filter matches images with the `com.example.version` label with the `1.0` value. 215 216 ```bash 217 $ docker images --filter "label=com.example.version=1.0" 218 219 REPOSITORY TAG IMAGE ID CREATED SIZE 220 match-me latest 511136ea3c5a About a minute ago 188.3 MB 221 ``` 222 223 In this example, with the `0.1` value, it returns an empty set because no matches were found. 224 225 ```bash 226 $ docker images --filter "label=com.example.version=0.1" 227 REPOSITORY TAG IMAGE ID CREATED SIZE 228 ``` 229 230 #### Filter images by time 231 232 The `before` filter shows only images created before the image with 233 given id or reference. For example, having these images: 234 235 ```bash 236 $ docker images 237 238 REPOSITORY TAG IMAGE ID CREATED SIZE 239 image1 latest eeae25ada2aa 4 minutes ago 188.3 MB 240 image2 latest dea752e4e117 9 minutes ago 188.3 MB 241 image3 latest 511136ea3c5a 25 minutes ago 188.3 MB 242 ``` 243 244 Filtering with `before` would give: 245 246 ```bash 247 $ docker images --filter "before=image1" 248 249 REPOSITORY TAG IMAGE ID CREATED SIZE 250 image2 latest dea752e4e117 9 minutes ago 188.3 MB 251 image3 latest 511136ea3c5a 25 minutes ago 188.3 MB 252 ``` 253 254 Filtering with `since` would give: 255 256 ```bash 257 $ docker images --filter "since=image3" 258 REPOSITORY TAG IMAGE ID CREATED SIZE 259 image1 latest eeae25ada2aa 4 minutes ago 188.3 MB 260 image2 latest dea752e4e117 9 minutes ago 188.3 MB 261 ``` 262 263 #### Filter images by reference 264 265 The `reference` filter shows only images whose reference matches 266 the specified pattern. 267 268 ```bash 269 $ docker images 270 271 REPOSITORY TAG IMAGE ID CREATED SIZE 272 busybox latest e02e811dd08f 5 weeks ago 1.09 MB 273 busybox uclibc e02e811dd08f 5 weeks ago 1.09 MB 274 busybox musl 733eb3059dce 5 weeks ago 1.21 MB 275 busybox glibc 21c16b6787c6 5 weeks ago 4.19 MB 276 ``` 277 278 Filtering with `reference` would give: 279 280 ```bash 281 $ docker images --filter=reference='busy*:*libc' 282 REPOSITORY TAG IMAGE ID CREATED SIZE 283 busybox uclibc e02e811dd08f 5 weeks ago 1.09 MB 284 busybox glibc 21c16b6787c6 5 weeks ago 4.19 MB 285 ``` 286 287 ### Format the output 288 289 The formatting option (`--format`) will pretty print container output 290 using a Go template. 291 292 Valid placeholders for the Go template are listed below: 293 294 | Placeholder | Description| 295 | ---- | ---- | 296 | `.ID` | Image ID | 297 | `.Repository` | Image repository | 298 | `.Tag` | Image tag | 299 | `.Digest` | Image digest | 300 | `.CreatedSince` | Elapsed time since the image was created | 301 | `.CreatedAt` | Time when the image was created | 302 | `.Size` | Image disk size | 303 304 When using the `--format` option, the `image` command will either 305 output the data exactly as the template declares or, when using the 306 `table` directive, will include column headers as well. 307 308 The following example uses a template without headers and outputs the 309 `ID` and `Repository` entries separated by a colon for all images: 310 311 ```bash 312 {% raw %} 313 $ docker images --format "{{.ID}}: {{.Repository}}" 314 315 77af4d6b9913: <none> 316 b6fa739cedf5: committ 317 78a85c484f71: <none> 318 30557a29d5ab: docker 319 5ed6274db6ce: <none> 320 746b819f315e: postgres 321 746b819f315e: postgres 322 746b819f315e: postgres 323 746b819f315e: postgres 324 {% endraw %} 325 ``` 326 327 To list all images with their repository and tag in a table format you 328 can use: 329 330 ```bash 331 {% raw %} 332 $ docker images --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}" 333 334 IMAGE ID REPOSITORY TAG 335 77af4d6b9913 <none> <none> 336 b6fa739cedf5 committ latest 337 78a85c484f71 <none> <none> 338 30557a29d5ab docker latest 339 5ed6274db6ce <none> <none> 340 746b819f315e postgres 9 341 746b819f315e postgres 9.3 342 746b819f315e postgres 9.3.5 343 746b819f315e postgres latest 344 {% endraw %} 345 ```