Home>Article>Operation and Maintenance> How to compress docker image
Compressed image:
1. Use docker export and docker import
docker export is used to save a container, so we need to have one This command can only be used with running containers.
docker export> export.tar
docker import is used to load the saved container, but it cannot be restored to a container, but to a mirror
docker import export.tar:[TAG]
It can be achieved with one command
docker export <容器ID> | docker import - <镜像名>[:标签]
Use export The image obtained after importing will not save the image history, so the image will become smaller.
The test image is not compressed, and the test/import image is a compressed image. You can see that it has become smaller:
2. Use docker-squash
github address: https://github.com/jwilder/docker-squash
docker save| sudo docker-squash -t newtag | docker load
For more related tutorials, please pay attention to PHP Chinese websitedocker tutorialColumn.
The above is the detailed content of How to compress docker image. For more information, please follow other related articles on the PHP Chinese website!