Why are Docker container images so large?

前端 未结 8 1914
被撕碎了的回忆
被撕碎了的回忆 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 17:57

    Yes the layer system is quite surprising. If you have a base image and you increment it by doing the following:

    # Test
    #
    # VERSION       1
    
    # use the centos base image provided by dotCloud
    FROM centos7/wildfly
    MAINTAINER JohnDo 
    
    # Build it with: docker build -t "centos7/test" test/
    
    # Change user into root
    USER root
    
    # Extract weblogic
    RUN rm -rf /tmp/* \
        && rm -rf /wildfly/* 
    

    The image has exactly the same size. That essentially means, you have to manage to put into your RUN steps a lot of extract, install and cleanup magic to make the images as small as the software installed.

    This makes life much harder...

    The dockerBuild is missing RUN steps without commit.

提交回复
热议问题