Why are Docker container images so large?

前端 未结 8 1929
被撕碎了的回忆
被撕碎了的回忆 2020-11-30 17:32

I made a simple image through Dockerfile from Fedora (initially 320 MB).

Added Nano (this tiny editor of 1MB size), and the size of the image has risen to 530 MB. I\

8条回答
  •  清歌不尽
    2020-11-30 18:03

    The following helped me a lot:

    After removing unused packages (e.g. redis 1200 mb freed) inside my container, I have done the following:

    1. docker export [containerID] -o containername.tar
    2. docker import -m "commit message here" containername.tar imagename:tag

    The layers get flatten. The size of the new image will be smaller because I've removed packages from the container as stated above.

    This took a lot of time to understand this and that's why I've added my comment.

提交回复
热议问题