Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker how to change repository name or rename image?

I'm trying to change 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?

like image 566
Timur Fayzrakhmanov Avatar asked Aug 08 '14 19:08

Timur Fayzrakhmanov


People also ask

Can I rename a docker image?

You can rename your docker image by docker tag command. Use the below given command to do that. To rename docker container, use the rename sub-command as shown, in the following example, we renaming the container discourse_app to a new name disc_app.

How do I change the docker image?

Docker images can now be edited simply and reliably. This is an example of a Dockerfile for a Zabbix monitoring container. To change the image used by an existing container, we must first delete it, then edit the Docker file to make the necessary changes, and then recreate the container using the new file.

Can we rename Dockerfile?

You may name your Dockerfiles however you like. The default filename is Dockerfile (without an extension), and using the default can make various tasks easier while working with containers.


2 Answers

docker image tag server:latest myname/server:latest 

or

docker image tag d583c3ac45fd myname/server:latest 

Tags are just human-readable aliases for the full image name (d583c3ac45fd...).

So you can have as many of them associated with the same image as you like. If you don't like the old name you can remove it after you've retagged it:

docker rmi server 

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

like image 110
Andy Avatar answered Sep 22 '22 23:09

Andy


As a shorthand you can run:

docker tag d58 myname/server:latest 

Where d58 represents the first 3 characters of the IMAGE ID,in this case, that's all you need.

Finally, you can remove the old image as follows:

docker rmi server 
like image 39
Mwiza Avatar answered Sep 20 '22 23:09

Mwiza