What is docker image reference?

Viewed 2679

Docker documentation mentions image reference in many places. However, running docker images command gives the list of images with the following properties: REPOSITORY, TAG, IMAGE ID, CREATED, SIZE - no reference. Is 'reference' a synonym for ID or digest, or something else?

2 Answers

The docker image reference is the combination of the REPOSITORY and TAG in this format REPOSITORY:TAG where they are both separated by :. So if you have an image with a REPOSITORY of IMAGE1 and a tag of latest the image reference would be IMAGE1:latest. The knowledge of an image reference would help you to filter by docker image list by reference by running:

docker images --filter=reference='myDocker*:*dev'

The above command will return all docker images that the repository name starts with myDocker and the tag name ends with dev.

To add on to Kelvin's answer, Reference is the Repository which you will use with the tag. Have a look the below example.

$ docker images

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

As you can see above, my reference would be respectively

busybox:latest
busybox:uclibc
busybox:musl
busybox:glibc

If you only use the reference as busybox, by default it will use the latest tag.

You can filter the images on the reference filter as well.

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

You use the image reference in Dockerfile as well when you build the image by using the FROM directive.

FROM busybox #Reference is used as you can see and automatically, `latest` tag will be pulled
...

Ref:- https://docs.docker.com/engine/reference/commandline/images/

Ref:- https://docs.docker.com/engine/reference/builder/#from

Related