Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
in DevOps and Agile by (29.3k points)

I'm trying to change the repository name of the image:

REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE

server              latest              d583c3ac45fd        26 minutes ago      685.5 MB

Hence I want to change the name server to something like myname/server:

REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE

myname/server       latest              d583c3ac45fd        26 minutes ago      685.5 MB

How can I do this?

2 Answers

0 votes
by (50.2k points)

For this you could use: 

docker tag server:latest myname/server:latest

or

docker tag d583c3ac45fd myname/server:latest

Tags are the aliases for the full image name (d583c3ac45fd...).

So you can have as many of them associated with the same image as you like. You can remove the old name after you've re-tagged it:

docker rmi server

That will just remove the alias/tag. Since d583c3ac45fd has other names, the actual image won't be deleted.

0 votes
by (1.3k points)

This is how you would use the docker tag command to add a new name to an existing image: 

sudo docker tag d583c3ac45fd myname/server:latest 

In this command, d583c3ac45fd is the current image identifier and it assigned a new name myname/server along with the latest tag. 

So after executing this command you can verify change by running the following:

sudo docker images

It shows you the list of images, and here you will find the name of the repository updated for your image. This is efficient in organizing images especially when preparing them for deployment or sharing on Docker Hub.

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...