I did a test on docker about the image size.
# docker images
REPOSITORY TAG IMAGE ID
CREATED SIZE
img_anaconda_installed latest 5bbdedd62fd3
21 seconds ago 2.79GB
img_anaconda latest 5d9dbd3c4a63
14 minutes ago 794MB
centos latest 196e0ce0c9fb
3 weeks ago 197MB
centos is the image I run 'docker pull centos', the size of it is 197M.
Then, I run a container of centos, and in the container I did yum install wget, yum install bzip2, download anaconda.sh file, and stop the container.
Then I did 'docker commit my_container img_anaconda' to make a new image. The image size is 794M. It is a little bit big size than what I thought.
Finally, I once again entered my_container to install anaconda. After I finished anaconda, I stopped the container and docker commit a new image whose name is img_anaconda_installed. The size of it is 2.79GB.
So my question is that the reason of the big size is only that anaconda is big, or docker commit does some other things causing it?
PS: anaconda.sh file's size is 103M.
The more layers an image have the larger the result size is.
If you update the yum repository (which I guess you do due to the fact that you add packages!) and then commit that layer, it will further increase the image size. If you clean up the cache it might decrease it a bit.
I would recommend writing a Dockerfile
instead of updating the image through running container, that way you got a lot more control over the layer count and you can test and tweak a whole lot more and see the result right away.
If you run docker history <image name>
you can see the size of the different layers too, that would give you a hint on where the issue is located.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With