2015-06-21 16:41:38 -04:00
# images
2023-01-06 13:04:05 -05:00
<!-- - MARKER_GEN_START -->
2016-07-07 14:43:18 -04:00
List images
2015-06-21 16:41:38 -04:00
2023-01-06 13:04:05 -05:00
### Aliases
`docker image ls` , `docker image list` , `docker images`
### Options
| Name | Type | Default | Description |
|:---------------------------------------|:---------|:--------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
2024-07-03 02:29:57 -04:00
| `-a` , `--all` | `bool` | | Show all images (default hides intermediate images) |
| [`--digests` ](#digests ) | `bool` | | Show digests |
2023-01-06 13:04:05 -05:00
| [`-f` ](#filter ), [`--filter` ](#filter ) | `filter` | | Filter output based on conditions provided |
| [`--format` ](#format ) | `string` | | Format output using a custom template:< br > 'table': Print output in table format with column headers (default)< br > 'table TEMPLATE': Print output in table format using the given Go template< br > 'json': Print in JSON format< br > 'TEMPLATE': Print output using the given Go template.< br > Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates |
2024-07-03 02:29:57 -04:00
| [`--no-trunc` ](#no-trunc ) | `bool` | | Don't truncate output |
| `-q` , `--quiet` | `bool` | | Only show image IDs |
2023-01-06 13:04:05 -05:00
<!-- - MARKER_GEN_END -->
2015-06-21 16:41:38 -04:00
2017-02-07 18:42:48 -05:00
## Description
2015-06-21 16:41:38 -04:00
The default `docker images` will show all top level
2016-02-02 00:57:59 -05:00
images, their repository and tags, and their size.
2015-06-21 16:41:38 -04:00
Docker images have intermediate layers that increase reusability,
decrease disk usage, and speed up `docker build` by
allowing each step to be cached. These intermediate layers are not shown
by default.
2016-02-02 00:57:59 -05:00
The `SIZE` is the cumulative space taken up by the image and all
2015-06-21 16:41:38 -04:00
its parent images. This is also the disk space used by the contents of the
Tar file created when you `docker save` an image.
An image will be listed more than once if it has multiple repository names
or tags. This single image (identifiable by its matching `IMAGE ID` )
2016-02-02 00:57:59 -05:00
uses up the `SIZE` listed only once.
2015-06-21 16:41:38 -04:00
2017-02-07 18:42:48 -05:00
## Examples
2015-06-21 16:41:38 -04:00
2017-02-07 18:42:48 -05:00
### List the most recently created images
2021-08-21 08:54:14 -04:00
```console
2017-02-07 18:42:48 -05:00
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
< none > < none > 77af4d6b9913 19 hours ago 1.089 GB
committ latest b6fa739cedf5 19 hours ago 1.089 GB
< none > < none > 78a85c484f71 19 hours ago 1.089 GB
docker latest 30557a29d5ab 20 hours ago 1.089 GB
< none > < none > 5ed6274db6ce 24 hours ago 1.089 GB
postgres 9 746b819f315e 4 days ago 213.4 MB
postgres 9.3 746b819f315e 4 days ago 213.4 MB
postgres 9.3.5 746b819f315e 4 days ago 213.4 MB
postgres latest 746b819f315e 4 days ago 213.4 MB
```
### List images by name and tag
2015-08-08 09:58:48 -04:00
The `docker images` command takes an optional `[REPOSITORY[:TAG]]` argument
that restricts the list to images that match the argument. If you specify
`REPOSITORY` but no `TAG` , the `docker images` command lists all images in the
given repository.
2023-12-13 18:06:16 -05:00
For example, to list all images in the `java` repository, run the following command:
2015-08-08 09:58:48 -04:00
2021-08-21 08:54:14 -04:00
```console
2017-02-07 18:42:48 -05:00
$ docker images java
REPOSITORY TAG IMAGE ID CREATED SIZE
java 8 308e519aac60 6 days ago 824.5 MB
java 7 493d82594c15 3 months ago 656.3 MB
java latest 2711b1d6f3aa 5 months ago 603.9 MB
```
2015-08-08 09:58:48 -04:00
2023-12-13 18:06:16 -05:00
The `[REPOSITORY[:TAG]]` value must be an exact match. This means that, for example,
2015-08-08 09:58:48 -04:00
`docker images jav` does not match the image `java` .
If both `REPOSITORY` and `TAG` are provided, only images matching that
2023-12-13 18:06:16 -05:00
repository and tag are listed. To find all local images in the `java`
repository with tag `8` you can use:
2015-08-08 09:58:48 -04:00
2021-08-21 08:54:14 -04:00
```console
2017-02-07 18:42:48 -05:00
$ docker images java:8
REPOSITORY TAG IMAGE ID CREATED SIZE
java 8 308e519aac60 6 days ago 824.5 MB
```
2015-08-08 09:58:48 -04:00
If nothing matches `REPOSITORY[:TAG]` , the list is empty.
2021-08-21 08:54:14 -04:00
```console
2017-02-07 18:42:48 -05:00
$ docker images java:0
2015-06-21 16:41:38 -04:00
2017-02-07 18:42:48 -05:00
REPOSITORY TAG IMAGE ID CREATED SIZE
```
2015-06-21 16:41:38 -04:00
2023-01-06 13:28:29 -05:00
### <a name="no-trunc"></a> List the full length image IDs (--no-trunc)
2017-02-07 18:42:48 -05:00
2021-08-21 08:54:14 -04:00
```console
2017-02-07 18:42:48 -05:00
$ docker images --no-trunc
REPOSITORY TAG IMAGE ID CREATED SIZE
< none > < none > sha256:77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182 19 hours ago 1.089 GB
committest latest sha256:b6fa739cedf5ea12a620a439402b6004d057da800f91c7524b5086a5e4749c9f 19 hours ago 1.089 GB
< none > < none > sha256:78a85c484f71509adeaace20e72e941f6bdd2b25b4c75da8693efd9f61a37921 19 hours ago 1.089 GB
docker latest sha256:30557a29d5abc51e5f1d5b472e79b7e296f595abcf19fe6b9199dbbc809c6ff4 20 hours ago 1.089 GB
< none > < none > sha256:0124422dd9f9cf7ef15c0617cda3931ee68346455441d66ab8bdc5b05e9fdce5 20 hours ago 1.089 GB
< none > < none > sha256:18ad6fad340262ac2a636efd98a6d1f0ea775ae3d45240d3418466495a19a81b 22 hours ago 1.082 GB
< none > < none > sha256:f9f1e26352f0a3ba6a0ff68167559f64f3e21ff7ada60366e2d44a04befd1d3a 23 hours ago 1.089 GB
tryout latest sha256:2629d1fa0b81b222fca63371ca16cbf6a0772d07759ff80e8d1369b926940074 23 hours ago 131.5 MB
< none > < none > sha256:5ed6274db6ceb2397844896966ea239290555e74ef307030ebb01ff91b1914df 24 hours ago 1.089 GB
```
2015-06-21 16:41:38 -04:00
2023-01-06 13:28:29 -05:00
### <a name="digests"></a> List image digests (--digests)
2015-06-21 16:41:38 -04:00
Images that use the v2 or later format have a content-addressable identifier
called a `digest` . As long as the input used to generate the image is
unchanged, the digest value is predictable. To list image digest values, use
the `--digests` flag:
2021-08-21 08:54:14 -04:00
```console
2017-02-07 18:42:48 -05:00
$ docker images --digests
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
localhost:5000/test/busybox < none > sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf 4986bf8c1536 9 weeks ago 2.43 MB
```
2015-06-21 16:41:38 -04:00
When pushing or pulling to a 2.0 registry, the `push` or `pull` command
output includes the image digest. You can `pull` using a digest value. You can
also reference by digest in `create` , `run` , and `rmi` commands, as well as the
`FROM` image reference in a Dockerfile.
2023-01-06 13:28:29 -05:00
### <a name="filter"></a> Filtering (--filter)
2015-06-21 16:41:38 -04:00
The filtering flag (`-f` or `--filter` ) format is of "key=value". If there is more
2023-12-13 18:06:16 -05:00
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"` ).
2015-06-21 16:41:38 -04:00
The currently supported filters are:
* dangling (boolean - true or false)
* label (`label=< key > ` or `label=<key>=<value>` )
2016-10-28 10:31:20 -04:00
* before (`< image-name > [:< tag > ]`, `<image id>` or `<image@digest>` ) - filter images created before given id or references
* since (`< image-name > [:< tag > ]`, `<image id>` or `<image@digest>` ) - filter images created since given id or references
2017-03-21 10:58:12 -04:00
* reference (pattern of an image reference) - filter images whose reference matches the specified pattern
2015-06-21 16:41:38 -04:00
2017-02-07 18:42:48 -05:00
#### Show untagged images (dangling)
2015-06-21 16:41:38 -04:00
2021-08-21 08:54:14 -04:00
```console
2017-02-07 18:42:48 -05:00
$ docker images --filter "dangling=true"
2015-06-21 16:41:38 -04:00
2017-02-07 18:42:48 -05:00
REPOSITORY TAG IMAGE ID CREATED SIZE
< none > < none > 8abc22fbb042 4 weeks ago 0 B
< none > < none > 48e5f45168b9 4 weeks ago 2.489 MB
< none > < none > bf747efa0e2f 4 weeks ago 0 B
< none > < none > 980fe10e5736 12 weeks ago 101.4 MB
< none > < none > dea752e4e117 12 weeks ago 101.4 MB
< none > < none > 511136ea3c5a 8 months ago 0 B
```
This will display untagged images that are the leaves of the images tree (not
2015-06-21 16:41:38 -04:00
intermediary layers). These images occur when a new build of an image takes the
2015-12-08 13:08:29 -05:00
`repo:tag` away from the image ID, leaving it as `<none>:<none>` or untagged.
A warning will be issued if trying to remove an image when a container is presently
using it. By having this flag it allows for batch cleanup.
2015-06-21 16:41:38 -04:00
2023-12-13 18:06:16 -05:00
You can use this in conjunction with `docker rmi` :
2015-06-21 16:41:38 -04:00
2021-08-21 08:54:14 -04:00
```console
2017-02-07 18:42:48 -05:00
$ docker rmi $(docker images -f "dangling=true" -q)
2015-06-21 16:41:38 -04:00
2017-02-07 18:42:48 -05:00
8abc22fbb042
48e5f45168b9
bf747efa0e2f
980fe10e5736
dea752e4e117
511136ea3c5a
```
2015-06-21 16:41:38 -04:00
2020-04-19 11:08:37 -04:00
Docker warns you if any containers exist that are using these untagged images.
2015-06-21 16:41:38 -04:00
2017-02-07 18:42:48 -05:00
#### Show images with a given label
2015-08-27 02:47:03 -04:00
The `label` filter matches images based on the presence of a `label` alone or a `label` and a
value.
The following filter matches images with the `com.example.version` label regardless of its value.
2021-08-21 08:54:14 -04:00
```console
2017-02-07 18:42:48 -05:00
$ docker images --filter "label=com.example.version"
2015-08-27 02:47:03 -04:00
2017-02-07 18:42:48 -05:00
REPOSITORY TAG IMAGE ID CREATED SIZE
match-me-1 latest eeae25ada2aa About a minute ago 188.3 MB
match-me-2 latest dea752e4e117 About a minute ago 188.3 MB
```
2015-08-27 02:47:03 -04:00
The following filter matches images with the `com.example.version` label with the `1.0` value.
2021-08-21 08:54:14 -04:00
```console
2017-02-07 18:42:48 -05:00
$ docker images --filter "label=com.example.version=1.0"
REPOSITORY TAG IMAGE ID CREATED SIZE
match-me latest 511136ea3c5a About a minute ago 188.3 MB
```
2015-08-27 02:47:03 -04:00
In this example, with the `0.1` value, it returns an empty set because no matches were found.
2021-08-21 08:54:14 -04:00
```console
2017-02-07 18:42:48 -05:00
$ docker images --filter "label=com.example.version=0.1"
REPOSITORY TAG IMAGE ID CREATED SIZE
```
2015-12-18 08:03:41 -05:00
2017-02-07 18:42:48 -05:00
#### Filter images by time
2016-05-25 07:49:10 -04:00
The `before` filter shows only images created before the image with
2023-12-13 18:06:16 -05:00
a given ID or reference. For example, having these images:
2016-05-25 07:49:10 -04:00
2021-08-21 08:54:14 -04:00
```console
2017-02-07 18:42:48 -05:00
$ docker images
2016-05-25 07:49:10 -04:00
2017-02-07 18:42:48 -05:00
REPOSITORY TAG IMAGE ID CREATED SIZE
image1 latest eeae25ada2aa 4 minutes ago 188.3 MB
image2 latest dea752e4e117 9 minutes ago 188.3 MB
image3 latest 511136ea3c5a 25 minutes ago 188.3 MB
```
2016-05-25 07:49:10 -04:00
2017-02-07 18:42:48 -05:00
Filtering with `before` would give:
2016-05-25 07:49:10 -04:00
2021-08-21 08:54:14 -04:00
```console
2017-02-07 18:42:48 -05:00
$ docker images --filter "before=image1"
2016-05-25 07:49:10 -04:00
2017-02-07 18:42:48 -05:00
REPOSITORY TAG IMAGE ID CREATED SIZE
image2 latest dea752e4e117 9 minutes ago 188.3 MB
image3 latest 511136ea3c5a 25 minutes ago 188.3 MB
```
2016-05-25 07:49:10 -04:00
Filtering with `since` would give:
2021-08-21 08:54:14 -04:00
```console
2017-02-07 18:42:48 -05:00
$ docker images --filter "since=image3"
REPOSITORY TAG IMAGE ID CREATED SIZE
image1 latest eeae25ada2aa 4 minutes ago 188.3 MB
image2 latest dea752e4e117 9 minutes ago 188.3 MB
```
2016-05-25 07:49:10 -04:00
2017-02-07 18:42:48 -05:00
#### Filter images by reference
2016-11-17 09:34:17 -05:00
The `reference` filter shows only images whose reference matches
the specified pattern.
2021-08-21 08:54:14 -04:00
```console
2017-04-16 13:56:00 -04:00
$ docker images
2017-02-07 18:42:48 -05:00
2017-04-16 13:56:00 -04:00
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox latest e02e811dd08f 5 weeks ago 1.09 MB
busybox uclibc e02e811dd08f 5 weeks ago 1.09 MB
busybox musl 733eb3059dce 5 weeks ago 1.21 MB
busybox glibc 21c16b6787c6 5 weeks ago 4.19 MB
2017-02-07 18:42:48 -05:00
```
2016-11-17 09:34:17 -05:00
Filtering with `reference` would give:
2021-08-21 08:54:14 -04:00
```console
2017-04-16 13:56:00 -04:00
$ docker images --filter=reference='busy*:*libc'
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox uclibc e02e811dd08f 5 weeks ago 1.09 MB
busybox glibc 21c16b6787c6 5 weeks ago 4.19 MB
2017-02-07 18:42:48 -05:00
```
2016-05-25 07:49:10 -04:00
2018-12-04 23:04:06 -05:00
Filtering with multiple `reference` would give, either match A or B:
2021-08-21 08:54:14 -04:00
```console
2018-12-04 23:04:06 -05:00
$ docker images --filter=reference='busy*:uclibc' --filter=reference='busy*:glibc'
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox uclibc e02e811dd08f 5 weeks ago 1.09 MB
busybox glibc 21c16b6787c6 5 weeks ago 4.19 MB
```
2023-01-06 13:28:29 -05:00
### <a name="format"></a> Format the output (--format)
2015-12-18 08:03:41 -05:00
The formatting option (`--format`) will pretty print container output
using a Go template.
Valid placeholders for the Go template are listed below:
2022-03-30 08:33:44 -04:00
| Placeholder | Description |
|-----------------|------------------------------------------|
| `.ID` | Image ID |
| `.Repository` | Image repository |
| `.Tag` | Image tag |
| `.Digest` | Image digest |
2017-02-07 18:42:48 -05:00
| `.CreatedSince` | Elapsed time since the image was created |
2022-03-30 08:33:44 -04:00
| `.CreatedAt` | Time when the image was created |
| `.Size` | Image disk size |
2015-12-18 08:03:41 -05:00
When using the `--format` option, the `image` command will either
output the data exactly as the template declares or, when using the
`table` directive, will include column headers as well.
The following example uses a template without headers and outputs the
2020-04-19 11:23:09 -04:00
`ID` and `Repository` entries separated by a colon (`:`) for all images:
2015-12-18 08:03:41 -05:00
2021-08-21 08:54:14 -04:00
```console
2017-02-07 18:42:48 -05:00
$ docker images --format "{{.ID}}: {{.Repository}}"
77af4d6b9913: < none >
b6fa739cedf5: committ
78a85c484f71: < none >
30557a29d5ab: docker
5ed6274db6ce: < none >
746b819f315e: postgres
746b819f315e: postgres
746b819f315e: postgres
746b819f315e: postgres
```
2015-12-18 08:03:41 -05:00
To list all images with their repository and tag in a table format you
can use:
2021-08-21 08:54:14 -04:00
```console
2017-02-07 18:42:48 -05:00
$ docker images --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}"
IMAGE ID REPOSITORY TAG
77af4d6b9913 < none > < none >
b6fa739cedf5 committ latest
78a85c484f71 < none > < none >
30557a29d5ab docker latest
5ed6274db6ce < none > < none >
746b819f315e postgres 9
746b819f315e postgres 9.3
746b819f315e postgres 9.3.5
746b819f315e postgres latest
```
2021-03-09 18:49:33 -05:00
To list all images in JSON format, use the `json` directive:
```console
$ docker images --format json
{"Containers":"N/A","CreatedAt":"2021-03-04 03:24:42 +0100 CET","CreatedSince":"5 days ago","Digest":"\u003cnone\u003e","ID":"4dd97cefde62","Repository":"ubuntu","SharedSize":"N/A","Size":"72.9MB","Tag":"latest","UniqueSize":"N/A","VirtualSize":"72.9MB"}
{"Containers":"N/A","CreatedAt":"2021-02-17 22:19:54 +0100 CET","CreatedSince":"2 weeks ago","Digest":"\u003cnone\u003e","ID":"28f6e2705743","Repository":"alpine","SharedSize":"N/A","Size":"5.61MB","Tag":"latest","UniqueSize":"N/A","VirtualSize":"5.613MB"}
2022-03-30 08:33:44 -04:00
```