Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of exporting and importing images between docker

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

I like to play docker very much, but I recently encountered a problem. There is a problem with the dns of the new machine given by the company, which causes the pull not to mirror.

There is no way, nothing can be done without mirroring, and we can't spend a lot of time building a private mirror library, so we have to find another way.

Nonsense, after exploration, it is found that docker provides a mechanism to export the image to export (save save) as a file, so that the image can be copy anywhere.

1. Export export-Import import

Format: docker export CONTAINER (container)

Use docker ps-a to view existing containers on the machine, such as:

We use the container furious_bell, and now we want to save the container as a file myunbuntu-export-1204.tar

Docker export furious_bell > / home/myubuntu-export-1204.tar

After the export is complete, you can use import to import

Docker import-/ home/myubuntu-export-1204.tar

two。 Save save-load load

Format: docker save IMAGE (mirrored)

Use docker images to view existing local images (you can also use the docker commit command to save a running container as an image), such as:

Here is a basic image: ubuntu:12.04. Now save this image as a file myubuntu-save-1204.tar

Docker save 9610cfc68e8d > / home/myubuntu-save-1204.tar

It's a little slow, wait a little bit, without any warn information, it means saving the OK. 9610cfc68e8d is a mirrored ID

Now you can load the newly saved image anywhere you install docker.

Docker load < / home/myubuntu-save-1204.tar

3. The difference between exporting export and saving save

(1) the size of the image file exported by .export is smaller than that saved by save

(2). Export export (import import) is based on the image obtained by the container, and all the history of the image will be lost when it is imported, so the rollback operation (docker tag) cannot be performed. While the image saved by save (loaded by load) has no history of image loss, it can be rolled back to the previous layer (layer). (view method: docker images-- tree)

Note: if you find it inappropriate to import and load, you can delete it by using docker rm container ID and docker rmi image ID.

Remove all containers and images (thorough cleaning):

The copy code is as follows:

Docker kill $(docker ps-Q); docker rm $(docker ps-a-Q); docker rmi $(docker images-Q-a)

Reference:

Http://www.tuicool.com/articles/emYVRzv

Http://my.oschina.net/zjzhai/blog/225112

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report