Schedule a FREE onboarding and start making pipelines fast.

Hello Whale: I’m Gonna Pop Some Tags…

Docker Tutorial | June 4, 2017

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

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

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…

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

…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:

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

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)…

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?:

and then push it to dockerhub with

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! 👩🏼‍🏫

About Chloe Condon

Developer Evangelist at Codefresh. Hackbright Alumni/Ambassador/Mentor/frequent conference speaker. Former actress, and one of the only humans who can code while singing the entire score of "Pirates of Penzance".

Reader Interactions

Enjoy this article? Don't forget to share.

Comments

Your email address will not be published. Required fields are marked *

Follow me on Twitter