weeklyright.blogg.se

Docker tag
Docker tag













docker tag

An image can have multiple tags and they’re usually used to specify major and minor versions. Since the tag is explicitly mentioned here, Docker will pull the Debian image tagged 9.3Īnother thing to keep in mind is that there is no rule which states that an image needs to have just one tag. Since we didn’t specify any tag, Docker will add the latest tag and try to pull the image debian:latest. Suppose the following statement is present in our Dockerfile: FROM debian Let’s consider the various scenarios with an example: Scenario 1: But I like to think of it as the default tag that’s given to images when you don’t specify one.Ī lot of confusion around latest is caused due to the expectation that it’s the latest version of the image, especially in Dockerfiles. It’s an unfortunate naming choice that causes a lot of confusion. Whenever an image is tagged without an explicit tag, it’s given the latest tag by default. This is where the latest tag comes into the picture.

docker tag

What happens when you don’t specify a tag?Īlright, now let’s uncover what happens when you don’t specify a tag while tagging an image. Notice how the tag is specified as optional here as well, by the.

docker tag

It’s like assigning an existing image another name to refer to it. This command just creates an alias (a reference) by the name of the TARGET_IMAGE that refers to the SOURCE_IMAGE. Explicitly tagging an image through the tag command. We’ll see what happens in that case soon.Ģ. As stated before, it’s not mandatory to specify a tag_name. This restriction usually doesn’t exist in private registries. For example, your image cannot have the name a/b/c:1. For the public Docker registry, you’re restricted to a two level hierarchy while naming images. Your image can be named anything you want. It’s just a useful convention to avoid tagging your image again when you need to push it to a registry. Username/image_name is not a mandatory format for specifying the name of the image. If you run docker images, you should see an image whose repository is username/image_name and tag is tag_name. Next, we tell the Docker daemon to build the image and give it the specified tag.

docker tag

We tell the Docker daemon to fetch the Docker file present in the current directory (that’s what the. Let’s try to unpack what this command does for a bit.

  • When building an image, we use the following command:ĭocker build -t username/image_name:tag_name.
  • The two most common cases where tags come into play are: A good analogy is how Git tags refer to a particular commit in your history. It’s just a way of referring to your image. They are aliases to the ID of your image which often look like this: f1477ec11d12. So, what exactly are Docker tags? In simple words, Docker tags convey useful information about a specific image version/variant. The documentation doesn’t explain them very well, and there really aren’t any thorough explanations on the topic. The tag is not always specified when tagging images, but we’ll get to the bottom of that later.Įver since I started using Docker, I’ve been very confused about tags. They often look like “my_image_name:1” where the part after the colon is known as a tag. If you’ve worked with Docker even for a little while, I bet you’ve come across tags.















    Docker tag