A running image is called a container. You can modify the container (such as deleting a file), but these changes do not affect the image. However, you can use the Docker commit command to turn a running container into a new image.
The Export command is used to persist the container (not mirroring). Therefore, we need to get the container ID by the following methods:
sudo docker ps-a
Then perform the export:
sudo docker export <container id> >/home/export.tar
The Save command is used to persist the image (not the container). Therefore, we need to get the image name by the following methods:
sudo docker images
Then execute the Save:
sudo docker save busybox-1 >/home/save.tar
The final result is a 2.8MB size tar file (slightly larger than using the Export command)
You can use Docker rm (Dockerps−q−a) to remove all containers at once, Dockerrmi (Docker ps-q-a) deletes all the containers at once, and Docker RMI (Docker images-q) deletes all the mirrors at once.
Now start importing the container you just exported:
# import Export.tar file
Cat/home/export.tar | sudo docker import-busybox-1-export:latest
# View image
sudo docker image S
# to check if the import is successful, is to start a new container, check if there is a/home/test directory (exists)
sudo docker run Busybox-1-export [-d/home/test] && Echo ' Directory found ' | | Echo ' Directory not found '
Use similar steps to import the image:
# import Save.tar file
Docker load
The exported version will be slightly smaller than the original version. That's because after exporting, history and metadata are lost. Execute the following command to find out:
# Show all layers of mirroring (layer)
sudo docker images--tree
Save and Reload (saveed-loaded) without losing the history and layers (layer) of the mirror. This means that you will not be able to roll back to the previous layer (layers) using the export and then import, and then you can roll back the entire image using the Save and reload mode (you can perform Docker tag <layer id> <image NAME > Roll back to the previous layer).