Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a Docker image "tag"?

Tags:

docker

tags

I'm looking for a definition of "Docker tag".

I read the docs and related SO posts and couldn't find anything.

like image 414
Max Heiber Avatar asked Jul 21 '16 13:07

Max Heiber


1 Answers

It's basically meta-data you can use to distinguish versions of your Docker images so you can preserve older copies or variants of a primary build.

If you've been using Docker, you can see a list of images and their tags via the docker images command. If you don't specify a tag for a local image, the default will be latest.

As you saw in the docs, to create a new tag the format is:

docker tag IMAGE[:TAG] IMAGE[:TAG]

Update: digest values

In the image repository, the image itself has an ID that can be referenced by a unique identifier called a digest which is a sha256 hash value, based on the layers that make up the image. (You might have seen this value when pulling an image.) You can have multiple tags for the same image -- the tags are only pointers, so creating multiple tags won't take up additional storage space.

Note that using static-named tags (like latest) is something of an anti-pattern since you can not be 100% sure exactly which image that is for a given usage. While a tag will only apply to one image at a time in a given image repository, it may not be the one your application is using. Your build system is responsible for keeping the tags updated and your Docker client is responsible for when to check for a newer image, so explicitly checking the digest value is always a good idea:

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:

docker images --digests

like image 71
ldg Avatar answered Oct 20 '22 23:10

ldg