Why is the mysql image created on docker so large

  docker, question

The novice has just started to learn how to create system images and images of various applications.
图片描述

I first made a mirror image of centos67 myself, then installed vim based on centos67, and the Docker Committee saved it as centos67vim.
After that, mysql5.6 was compiled and installed based on centos67vim. Then, mysql56 was saved by commit, but the capacity reached 1.591GB

I found out why only 360.3 is officially provided by docker pull mysql.

Thank you for your great help! !

In the process of making the mirror image, we should pay attention to several points:
1. the file system is UnionFs in Dockerfile.Every RUNA layer is generated. So we need to clean up the generated data after each RUN. Because the generated result (3G size) is a linear superposition of various levels of size.
2. Why is the official mirror image generally smaller? Let’s take mysql:5.6 as a reference to analyze:

RUN apt-get update && apt-get install -y perl –no-install-recommends && rm -rf /var/lib/apt/lists/*
After updating the build, apt’s cached package file was then deleted. Generally speaking, this folder will occupy about 100M depending on the situation.

RUN { …&& apt-get update && apt-get install -y
mysql-server=”${MYSQL_VERSION}” && rm -rf /var/lib/apt/lists/* && rm
-RF/var/lib/MySQL & & mkdir-p/var/lib/MySQL routinely deletes cached package files after db is installed. Deleting /var/lib/mysql can clear the sample database.

When we look at vim packages that are most commonly used in hub.docker.com, we find that the haron/vim image is the scratch used for 300M as the basic image.

After a rough search in hub.docker.com, there is no mysql image based on centos. Personal estimation is that the cached package was not deleted, resulting in the problem.

As for the basic mirror size mentioned by the @ShawnTaoo brothers, I also made the following survey: Centos: Latest190+MB, Debian: Jessie: 130+MB, Ubuntu: Latest180+MB


References:

  1. Mysql Mirror Analysis

  2. Haron/vim analysis

  3. Centos basic image analysis

  4. Ubuntu basic image analysis