Docker tutorial on how to save and load images remove and implement images

  • 2020-05-30 21:42:33
  • OfStack

Save and load images

Save the image

If you want to export the image to a local file, you can use the docker save command.

$ sudo docker images
ubuntu       14.04        c4ff7513909d    5 weeks ago     225.4 MB
$sudo docker save -o ubuntu_14.04.tar ubuntu:14.04

Load the image

You can use docker load to import from an exported local file into a local mirror library, for example

$ sudo docker load --input ubuntu_14.04.tar


$ sudo docker load < ubuntu_14.04.tar

This imports the image and its associated metadata information (including labels and so on).


If you want to remove a local image, you can use the docker rmi command. Note that the docker rm command is to remove the container.

$ sudo docker rmi training/sinatra
Untagged: training/sinatra:latest
Deleted: 5bc342fa0b91cabf65246837015197eecfa24b2213ed6a51a8974ae250fedd8d
Deleted: ed0fffdcdae5eb2c3a55549857a8be7fc8bc4241fb19ad714364cbfd7a56b22f
Deleted: 5c58979d73ae448df5af1d8142436d81116187a7633082650549c52c3a2418f0

Note: docker rm is used to delete all containers that depend on the image before deleting it.

The implementation principle of mirroring

How is the Docker image incrementally modified and maintained? Each mirror is composed of many layers, and Docker USES Union FS to combine these different layers into one mirror.

Usually Union FS has two purposes, one aspect can not achieve using LVM, RAID multiple disk hung with a directory, the other one is more commonly used is to a read-only branch and 1 can be written by branch joint in 1 case, Live CD was based on this method can be allowed on the basis of mirror constant allows the user to 1 in the write operation. Docker's container built on top of AUFS takes advantage of a similar principle.

Thank you for reading, I hope to help you, thank you for your support of this site!

Related articles: