How to Tag and Push a Docker Image to a Private Registry

Tremaine Eto
Jan 7 · 3 min read
Image for post
Image for post
Original photo by Rubén Bagüés on Unsplash; logo by Docker; text by Tremaine Eto

Let’s say that you’re working on an application, sandbox/tremaine-test-app, on your local machine and you just made the image. When you run $ docker images, you are able to see the image amidst all the other images saved to your machine.

Now, you want to push it to your private Docker repository so that your friend across the country can pull it and then run and test it on their machine. However, you want to change the name of the image, and you want to also mark it as a SNAPSHOT version to emphasize that it’s not really intended to be a formal release.

More than purely aesthetic reasons of possibly re-naming the image, tagging is important because it tells Docker the repository you wish to place the image in on the registry side.

Tag it!

The key here is to tag the image. This basically means that you re-name the image. It follows the following format:

The tags, which are optional as denoted by the parentheses, must be comprised of ASCII characters, digits, underscores, periods, and dashes; additionally, it can’t start with a period or dash, and it can’t exceed 128 characters.

The yourRegistryHost:<port> corresponds with the hostname of your private Docker registry along with a port, if necessary. This is for later when you’re pushing the newly-tagged Docker image.

It turns out that there are a lot of different methods you can use to tag a local image.

If we take a look at the list given to us by $ docker images earlier in the article, we saw the images’ corresponding image IDs. We can use one of those in this command and Docker’s CLI will know to reference that ID.

In the earlier example, sandbox/tremaine-test-app had both a 1.0.0 and a latest version, but their image IDs were the same. That’s because they are the same image in reality; if there were more tags of sandbox/tremaine-test-app with different versions, then that one may not necessarily be the latest one, and therefore they may have different image IDs.

In this example, and all the subsequent ones, we are tagging our local sandbox/tremaine-test-app image with tremaine/hello-world:1.0.0-SNAPSHOT.

By doing that, we’re saying that we want to have a new tag of the image called hello-world with version tag 1.0.0-SNAPSHOT to be placed in the tremaine repository.

In this case, we explicitly use the image name to be used as the source image. I like this approach because it’s easier for me to remember my image name as opposed to copy and pasting the image ID.

In this case, we did not specify a tag in our source (leftmost) image, and so Docker will infer that it is for the latest tag.

This is quite similar to the last example, but in this one, we didn’t want it to default to the latest tag for the source image. Therefore, we specified 1.0.0 specifically.

Push it!

Now that we have our tagged image, yourRegistryHost:<port>/tremaine/hello-world:1.0.0-SNAPSHOT, we can push it to our private Docker registry with a simple command:

Since we already have the Docker host in the image, Docker will know to push it there.

The push will take a little bit of time, but when it’s all said and done, your friend will be able to run $ docker pull to pull the image to their machine and then run it as they please.

In a later article to be linked here when published, I will go over some finer details and options available with $ docker push.

Dev Genius

Coding, Tutorials, News, UX, UI and much more related to development

By Dev Genius

The best stories sent monthly to your email. Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Tremaine Eto

Written by

Full-time software engineer since 2016. UCLA Computer Science B.S. with Atmospheric and Oceanic Sciences minor, class of ‘16.

Dev Genius

Coding, Tutorials, News, UX, UI and much more related to development

Tremaine Eto

Written by

Full-time software engineer since 2016. UCLA Computer Science B.S. with Atmospheric and Oceanic Sciences minor, class of ‘16.

Dev Genius

Coding, Tutorials, News, UX, UI and much more related to development

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store