How to compress docker image

Release: 2020-04-02 11:47:25
Original
5614 people have browsed it

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
Copy after login

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]
Copy after login

It can be achieved with one command

docker export <容器ID> | docker import - <镜像名>[:标签]
Copy after login

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:

How to compress docker image

2. Use docker-squash

github address: https://github.com/jwilder/docker-squash

docker save  | sudo docker-squash -t newtag | docker load
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!