Home>Article>Operation and Maintenance> How to compress docker image

How to compress docker image

尚
Original
2020-04-02 11:47:25 5624browse

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:

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

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!

Statement:
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