官术网_书友最值得收藏!

Saving and loading images

The Docker CLI allows us to export and import Docker images and container layers using export/import or save/load Docker commands. The difference between save/load and export/import is that the first one works with images including metadata, but the export/import combination uses only container layers and doesn't include any image metadata information such as name, tags, and so on. In most cases, the save/load combination is more relevant and works properly for images without special needs. The docker save command packs the layers and metadata of all the chains required to build the image. You can then load this saved images chain into another Docker instance and create containers from these images.

The docker export will fetch the whole container, like a snapshot of a regular VM. It saves the OS, of course, but also any change a you made and any data file written during the container life. This one is more like a traditional backup:

$ docker save httpd -o httpd.tar

$ ls -l httpd.tar

To load the image back from the file, we can use the docker load command. Before we do that, though, let's remove the httpd image from the local repository first:

$ docker rmi httpd:latest

The output of the preceding command will be as shown in the following screenshot:

We verify that we do not have any images in the local repository:

 $ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE

Load the image file we previously saved with the docker save command. Like docker export and docker import, this command forms a pair with Docker save and thus is used for loading a saved container archive with all intermediate layers and metadata to the Docker cache:

$ docker load -i httpd.tar

The output of the preceding command will be as shown in the following screenshot:

Check the local docker images with docker image command:

$ docker images

The output of the preceding command will be as shown in the following screenshot:

主站蜘蛛池模板: 洱源县| 石首市| 北宁市| 湘阴县| 额济纳旗| 漠河县| 桐梓县| 东丽区| 泗水县| 怀集县| 宾川县| 潼关县| 册亨县| 新田县| 普兰店市| 苏尼特左旗| 芜湖县| 新平| 勐海县| 呼伦贝尔市| 平南县| 沙湾县| 洛阳市| 永胜县| 周宁县| 南陵县| 洪江市| 鄂托克前旗| 澄江县| 化州市| 安宁市| 衡阳市| 格尔木市| 布拖县| 土默特右旗| 黄冈市| 阜宁县| 浦北县| 岳普湖县| 南宁市| 荔浦县|