Docker Size Investigation

Docker Jul 10, 2023

This is a time when you Docker size is BIG!

Then we need to see inside.

Command

Start your CLI inside the Docker

docker run -it --entrypoint /bin/sh <your_container_name>
It is important to skip entrypoint that will sometimes break the run if you not yet inject any environment.

Investigate space with command

du -sch *

to see the summary of the result

Then the hidden files

du -sh .[^.]*

Here we have unnecessary .git folder and also .vscode too.

Now we can have some common mistake list:

Common mistake

  1. Include .git repos
  2. Include files that need to be ignore
  3. Include source code not only build artifact
  4. Include development file e.g. VSCode, Patch

If you do some of this, size can be reduce by about 25% or even half.

Hope this helps

Cheers !

Tags

TeamCMD

We are CODEMONDAY team and provide a variety of content about Business , technology, and Programming. Let's enjoy it with us.