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 skipentrypoint
that will sometimes break therun
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
- Include
.git
repos - Include files that need to be ignore
- Include source code not only
build
artifact - 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 !