Create your FREE Codefresh account and start making pipelines fast. Create Account

Hello Whale: I’m Gonna Pop Some Tags…

3 min read

If you’re a Docker user,  when you run…

docker image ls

…you’ve seen something similar to this, listing out the info of our images:

REPOSITORY TAG IMAGE ID CREATED SIZE

nginx latest 46102226f2fd 5 weeks ago 109 MB
mysql latest 9e64176cd8a2 5 weeks ago 407 MB
httpd latest ef0aca83ba5a 5 weeks ago 177 MB
ubuntu latest f7b3f317ec73 5 weeks ago 117 MB
hello-world latest 48b5124b2768 4 months ago 1.84 kB
docker/whalesay latest 6b362a9f73eb 2 years ago 247 MB

As you can see, we have 3 ways to identify the images: REPOSITORY, TAG, AND IMAGE ID. Since repositories can have duplicate names, and the image IDs… well, who can remember a name like “db079554b4d2”? We sometimes need an easy way to identify them….

Enter Tags!

Sadly, not the Macklemore type of “tags”, but I personally find learning about Docker just as fun as thrift shopping… but I digress.

In the world of Docker, tags point to specific image commit (or, image ID). You can think of it like a symlink from Unix based OS’s. You’ve probably seen the tag “latest” quite a bit while playing with Docker- think of this as a default tag in Docker, and less of a “most recent” type description.

For example, if I go to the official Python registry on DockerHub, the full description area lists all the “Supported tags” as numbers as well as version numbers with words. As you can see, the images here can have multiple tags associated with them. For example, these are all tags of the same image:

2.7.13-wheezy, 2.7-wheezy, 2-wheezy (2.7/wheezy/Dockerfile)

So, if I run the following…

docker pull python:2-wheezy

I now have that image of Python. And, if I run…

docker pull python:2.7-wheezy

…Docker is intelligent enough to know that this image is already in my cache. So, if I check on my images by running the following:

docker image ls

you’ll see 2 python images with different tags, but the same image ID. Starting to make sense? Image caching is one of the awesome parts of Docker that makes it so lightweight!

“But Chloe, I want to change the tag on my image! ‘Wheezy’ is a weird name!”

Well, that’s pretty simple. If I run

docker image tag python:2-wheezy chloecodesthings/python:yoyowazzup

and then run docker image ls….

There’s a new tag added to an existing image labeled with my username. Whoa! So now, if I run (you’ll have to be logged into Docker on your terminal for this)…

docker image push chloecodesthings/python

BOOM! There it is in my repo!

By giving a new tag to the existing image, when I push to Docker it’ll create a new repo for me. And when I go to tags…. Oh hey, there’s my “yoyowazzup” tag!

Clearly, that’s not a great tag name, but I wanted to demonstrate that your tag doesn’t have to be “latest” or a numerical value. Let’s switch to something more professional, shall we?:

docker image tag chloecodesthings/python chloecodesthings/python:v.1

and then push it to dockerhub with

docker image push chloecodesthings/python:v.1

Hey- look a that! Another tag for our image! Same image- different tags. Making a little more sense now? Having multiple/different tags on the same image won’t change it. You can just think of it as multiple names for the same image. So, I (Chloe) can also go by “Chlobot”, “Chlo”, “The Chlo-ster”, but I’m still the same person underneath it all 🙂

One of my favorite features of Codefresh is all the meta-data that we list for images. Having all this info in one place is extremely valuable- not only can I see things such as my SHA, Branch, Image Size, Pipeline, Dockerfile, Logs, Layers, etc., but I can actually view and update my tags from here as well! If you want to test out this feature on Codefresh and see what its like to have incredibly fast building/testing/deployment with Docker, visit our site today or comment below to schedule a demo with me! 👩🏼‍🏫

Contributor

Leave a Reply

* All fields are required. Your email address will not be published.