- Learn OpenShift
- Denis Zuev Artemii Kropachev Aleksey Usov
- 339字
- 2021-08-13 16:03:45
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:
- Designing Purpose:Built Drones for Ardupilot Pixhawk 2.1
- 蘋果電腦玩全攻略 OS X 10.8 Mountain Lion
- 精解Windows 8
- 操作系統基礎與實踐:基于openEuler平臺
- Windows Phone 7.5 Data Cookbook
- 嵌入式Linux應用開發菜鳥進階
- Instant Optimizing Embedded Systems using Busybox
- Windows 7案例教程
- Fedora 12 Linux應用基礎
- RHCSARHCE 紅帽Linux認證學習指南(第7版)EX200 & EX300
- Kali Linux高級滲透測試(原書第3版)
- Web Penetration Testing with Kali Linux(Third Edition)
- Zabbix監控系統之深度解析和實踐
- CSS揭秘
- openEuler操作系統核心技術與行業應用實踐