How I Change Name of My Docker Repository and Rename Images?

Have you ever found yourself needing to change the repository name or rename a Docker image?

I recently faced this challenge and got to know that it is a very simple yet effective process to accomplish it. In this blog post, I want to share my step-by-step process of changing the repository name and renaming Docker images.

Let's dive in together!

Section 1: Understanding Docker Image Tags

Before we get started, let's take a moment to understand Docker image tags.

Docker images are identified by their repository name and tag. Think of the tag as a version or variant of the image.

For example, I had an image called myimage:v1, where myimage is the repository name and v1 is the tag.

Section 2: Tagging the Existing Image

To change the repository name or rename a Docker image, the first step is to tag the existing image with the new repository name.

Don't worry, it's easier than it sounds! Let me show you the command I used in my terminal:

1#Please replace the existing image name as well as new repository name  
3docker tag <existing_image>:<tag> <new_repository>:<tag>

In my case, I had an image named myimage in the repository oldrepo with the tag v1. I wanted to rename it to newrepo while keeping the same tag. So, the command I ran looked like this:

1# Existing repo name = oldrepo
2# New Repo name = newrepo
3# Tag = v1 (no need to change the tag)
5docker tag oldrepo/myimage:v1 newrepo/myimage:v1

docker tag old image to new image

By executing this command, I created a new tag for the image with the desired repository name. It felt like giving my image a fresh identity!

You can also verify the newly renamed docker image by running the following docker command:

1# List all the docker images 
3docker image ls  

List all docker images

Section 3: Pushing the Newly Tagged Image

Once I had tagged the image with the new repository name, the next step was to push it to the Docker registry.

This step allows me to share the image with others and deploy it easily.

Here's the command syntax I used for pushing the docker image:

1# Docker push command to push the docker image
3docker push <new_repository>:<tag>

In my case, I executed:

1# Docker command to push docker image to newrepo 
3docker push newrepo/myimage:v1

With this command, the image with the new repository name was uploaded to the Docker registry. It felt great to see my renamed image ready to be used by others!

Section 4: Removing the Old Image (Optional)

If you prefer, you can remove the old image from your local machine. However, please proceed with caution, as other containers or images may still rely on it. To remove the old image, I used the following command:

1#Remove old unused image 
3docker rmi <existing_image>:<tag> 

For instance, I ran:

1# Remove the old image
2docker rmi oldrepo/myimage:v1 

Remember, this step is optional. Only remove the old image if you are confident it won't affect other parts of your Docker environment.


I successfully changed the repository name and renamed my Docker image. By following the steps I shared in this blog post, you too can easily update repository names and rename Docker images whenever needed.

I hope my personal experience and step-by-step guide have been helpful to you. If you have any questions or need further assistance, please feel free to reach out. Let's continue exploring the vast possibilities Docker offers together!

Posts in this Series