CODEMONDAY
Published in

CODEMONDAY

Docker Size Investigation

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 !

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store