Friday, April 8, 2022

[SOLVED] Docker image over growing

Issue

I have 3 simple docker files. In every file I install python3 on the base image (centos:7, oraclelinux:7-slim and alpine:latest).

The python3 installation process indicates the installed files (python3 and dependencies) are about 50MB. But when I build the new images, the centos image grows from 204MB to 413MB, the oraclelinux image grows from 132MB to 480MB and alpine grows from 5.59MB to 54MB. So, only new alpine image make sense as it grows almost 50MB. But why are new centos and oraclelinux images so larger than they should be?

Dockerfile for centos:

FROM centos:7
RUN yum install -y python3

Dockerfile for oraclelinux:

FROM oraclelinux:7-slim
RUN yum install -y python3

Dockerfile for alpine:

FROM alpine:latest
RUN apk add python3

Solution

Alpine Image used be have less size.

  • an Alpine Linux is a Linux distribution built around musl, libc and BusyBox. The image is only 5 MB in size and has access to a package repository that is much more complete than other BusyBox based images.

    FROM alpine:latest # 5 MB RUN apk add python3 # adding another layer of python3 I:e 40+MB

Why are new centos images so larger?

For CentOS you need to run yum clean all and SO Answer



Answered By - Gupta
Answer Checked By - Candace Johnson (WPSolving Volunteer)