简体   繁体   中英

Docker image save how to check if exist before load?

This way I can make a backup of an existing docker image to a safe place:

docker save  -o  /backitup/myimage.tar   myimage:v1

Then I can restore the image to another host or on the same with:

cat  /backitup/myimage.tar  | docker import --message "New image imported from tarball" - myimage:v1

But how will I know if the same image is already on the host maybe with a different name?

REPOSITORY           TAG                 IMAGE ID       CREATED              SIZE
myimage             v1                  1b6ef4d470ef   3 seconds ago        577MB
stillmyimage        dupe                a9a1468fdebf   4 minutes ago        577MB

This command replace the import and does exactly the job, load with name and don't create new if exist:

docker load < /backitup/myimage.tar

Loaded image: myimage:v1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM