2015-06-08 13:48:20 -04:00
|
|
|
This command lists the images stored in the local Docker repository.
|
|
|
|
|
|
|
|
By default, intermediate images, used during builds, are not listed. Some of the
|
|
|
|
output, e.g., image ID, is truncated, for space reasons. However the truncated
|
|
|
|
image ID, and often the first few characters, are enough to be used in other
|
|
|
|
Docker commands that use the image ID. The output includes repository, tag, image
|
|
|
|
ID, date created and the virtual size.
|
|
|
|
|
|
|
|
The title REPOSITORY for the first title may seem confusing. It is essentially
|
|
|
|
the image name. However, because you can tag a specific image, and multiple tags
|
|
|
|
(image instances) can be associated with a single name, the name is really a
|
|
|
|
repository for all tagged images of the same name. For example consider an image
|
|
|
|
called fedora. It may be tagged with 18, 19, or 20, etc. to manage different
|
|
|
|
versions.
|
|
|
|
|
2016-09-22 14:11:08 -04:00
|
|
|
## Filters
|
2015-06-08 13:48:20 -04:00
|
|
|
|
2016-09-22 14:11:08 -04:00
|
|
|
Filters the output based on these conditions:
|
2015-06-08 13:48:20 -04:00
|
|
|
|
2016-10-28 10:31:20 -04:00
|
|
|
- dangling=(true|false) - find unused images
|
2016-05-25 07:49:10 -04:00
|
|
|
- label=<key> or label=<key>=<value>
|
|
|
|
- before=(<image-name>[:tag]|<image-id>|<image@digest>)
|
|
|
|
- since=(<image-name>[:tag]|<image-id>|<image@digest>)
|
2017-03-21 10:58:12 -04:00
|
|
|
- reference=(pattern of an image reference)
|
2015-06-08 13:48:20 -04:00
|
|
|
|
2016-09-22 14:11:08 -04:00
|
|
|
## Format
|
|
|
|
|
2016-09-02 05:51:41 -04:00
|
|
|
Pretty-print images using a Go template.
|
2015-12-18 08:03:41 -05:00
|
|
|
Valid placeholders:
|
|
|
|
.ID - Image ID
|
|
|
|
.Repository - Image repository
|
|
|
|
.Tag - Image tag
|
|
|
|
.Digest - Image digest
|
2016-10-28 10:31:20 -04:00
|
|
|
.CreatedSince - Elapsed time since the image was created
|
|
|
|
.CreatedAt - Time when the image was created
|
|
|
|
.Size - Image disk size
|
2015-12-18 08:03:41 -05:00
|
|
|
|
2015-06-08 13:48:20 -04:00
|
|
|
# EXAMPLES
|
|
|
|
|
|
|
|
## Listing the images
|
|
|
|
|
|
|
|
To list the images in a local repository (not the registry) run:
|
|
|
|
|
2016-09-22 14:11:08 -04:00
|
|
|
docker image ls
|
2015-06-08 13:48:20 -04:00
|
|
|
|
|
|
|
The list will contain the image repository name, a tag for the image, and an
|
|
|
|
image ID, when it was created and its virtual size. Columns: REPOSITORY, TAG,
|
2016-02-02 00:57:59 -05:00
|
|
|
IMAGE ID, CREATED, and SIZE.
|
2015-06-08 13:48:20 -04:00
|
|
|
|
2016-09-22 14:11:08 -04:00
|
|
|
The `docker image ls` command takes an optional `[REPOSITORY[:TAG]]` argument
|
2015-08-08 09:58:48 -04:00
|
|
|
that restricts the list to images that match the argument. If you specify
|
2017-02-18 21:56:29 -05:00
|
|
|
`REPOSITORY` but no `TAG`, the `docker image ls` command lists all images in the
|
2015-08-08 09:58:48 -04:00
|
|
|
given repository.
|
|
|
|
|
2016-09-22 14:11:08 -04:00
|
|
|
docker image ls java
|
2015-08-08 09:58:48 -04:00
|
|
|
|
|
|
|
The `[REPOSITORY[:TAG]]` value must be an "exact match". This means that, for example,
|
2016-09-22 14:11:08 -04:00
|
|
|
`docker image ls jav` does not match the image `java`.
|
2015-08-08 09:58:48 -04:00
|
|
|
|
|
|
|
If both `REPOSITORY` and `TAG` are provided, only images matching that
|
|
|
|
repository and tag are listed. To find all local images in the "java"
|
|
|
|
repository with tag "8" you can use:
|
|
|
|
|
2016-09-22 14:11:08 -04:00
|
|
|
docker image ls java:8
|
2015-08-08 09:58:48 -04:00
|
|
|
|
2015-06-08 13:48:20 -04:00
|
|
|
To get a verbose list of images which contains all the intermediate images
|
|
|
|
used in builds use **-a**:
|
|
|
|
|
2016-09-22 14:11:08 -04:00
|
|
|
docker image ls -a
|
2015-06-08 13:48:20 -04:00
|
|
|
|
2016-09-22 14:11:08 -04:00
|
|
|
Previously, the docker image ls command supported the --tree and --dot arguments,
|
2015-06-08 13:48:20 -04:00
|
|
|
which displayed different visualizations of the image data. Docker core removed
|
|
|
|
this functionality in the 1.7 version. If you liked this functionality, you can
|
|
|
|
still find it in the third-party dockviz tool: https://github.com/justone/dockviz.
|
|
|
|
|
2016-11-22 19:24:17 -05:00
|
|
|
## Listing images in a desired format
|
|
|
|
|
|
|
|
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. You can use special characters like `\t` for
|
|
|
|
inserting tab spacing between columns.
|
|
|
|
|
|
|
|
The following example uses a template without headers and outputs the ID and
|
|
|
|
Repository entries separated by a colon for all images:
|
|
|
|
|
|
|
|
docker images --format "{{.ID}}: {{.Repository}}"
|
|
|
|
77af4d6b9913: <none>
|
|
|
|
b6fa739cedf5: committ
|
|
|
|
78a85c484bad: ipbabble
|
|
|
|
30557a29d5ab: docker
|
|
|
|
5ed6274db6ce: <none>
|
|
|
|
746b819f315e: postgres
|
|
|
|
746b819f315e: postgres
|
|
|
|
746b819f315e: postgres
|
|
|
|
746b819f315e: postgres
|
|
|
|
|
|
|
|
To list all images with their repository and tag in a table format you can use:
|
|
|
|
|
|
|
|
docker images --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}"
|
|
|
|
IMAGE ID REPOSITORY TAG
|
|
|
|
77af4d6b9913 <none> <none>
|
|
|
|
b6fa739cedf5 committ latest
|
|
|
|
78a85c484bad ipbabble <none>
|
|
|
|
30557a29d5ab docker latest
|
|
|
|
5ed6274db6ce <none> <none>
|
|
|
|
746b819f315e postgres 9
|
|
|
|
746b819f315e postgres 9.3
|
|
|
|
746b819f315e postgres 9.3.5
|
|
|
|
746b819f315e postgres latest
|
|
|
|
|
|
|
|
Valid template placeholders are listed above.
|
|
|
|
|
2015-06-08 13:48:20 -04:00
|
|
|
## Listing only the shortened image IDs
|
|
|
|
|
|
|
|
Listing just the shortened image IDs. This can be useful for some automated
|
|
|
|
tools.
|
|
|
|
|
2016-09-22 14:11:08 -04:00
|
|
|
docker image ls -q
|