How to rename docker image name?

Viewed 18881

I saved a file whose format is .tar by docker save ,and then I load it into another server by docker load. When it succeeded, the docker give me a tip which is showed in following word.

The image file:V2.0.0Beta1-test already exists, renaming the old one with ID sha256:46952aea8dd30da5a2645d28930381c0ed5f72acd4fac43ea8556cc360d22cf7 to empty string
Loaded image: file:V2.0.0Beta1-test

And the old image should be saved,the new one need to save.What should I do now?

1 Answers

You can tag a docker image using docker tag, actually, it creates an image with a name that you specify in docker tag command.

Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE

Tag an image referenced by ID

To tag a local image with ID “0e5574283393” into the “fedora” repository with “version1.0”:

$ docker tag 0e5574283393 fedora/httpd:version1.0

Suppose you have an image named Beta1-test, you can tag like

docker tag Beta1-test Beta1-test_old

This will tag the Beta1-test image with new Beta1-test to Beta1-test_old.

Docker tag is just a way of referring to your image. So you can remove the Beta1-test using

docker rmi -f Beta1-test

now, as you have that image with new tag Beta1-test_old

Now you are able to build image like docker build -t Beta1-test

Beta1-test this is your new image after the build, and we tag the previous one with Beta1-test_old.

You have both new having name Beta1-test and old having name Beta1-test_old

You can view you docker images using this command.

docker images

or

docker images Beta1-test
Related