Every time I build my docker image it appears to grow in 5-10mb for no apparent reason.
Each time I am building, I'm adding a single line comment to a ruby.
Below are 3 images that are built with single line changes to the code and running docker -it <img_id> /bin/sh
and then du -d1
from the root. All 3 have no blocks/file-size differences.
Any idea as to why I'm losing 5-10mb per build?
9add242d3e75 2 hours ago 438MB
# du -d1
4 ./run
1472 ./var
4 ./opt
4 ./tmp
4972 ./lib
0 ./proc
4 ./srv
4 ./mnt
359692 ./usr
16 ./media
264 ./sbin
0 ./dev
0 ./sys
1740 ./etc
1084 ./bin
8 ./root
4 ./home
42024 ./app
411300 .
45ed1ea39f3a 13 hours ago 432MB
# du -d1
4 ./run
1472 ./var
4 ./opt
4 ./tmp
4972 ./lib
0 ./proc
4 ./srv
4 ./mnt
359692 ./usr
16 ./media
264 ./sbin
0 ./dev
0 ./sys
1740 ./etc
1084 ./bin
8 ./root
4 ./home
42024 ./app
411300 .
4740856ed1b7 13 hours ago 421MB
# du -d1
4 ./run
1472 ./var
4 ./opt
4 ./tmp
4972 ./lib
0 ./proc
4 ./srv
4 ./mnt
359692 ./usr
16 ./media
264 ./sbin
0 ./dev
0 ./sys
1740 ./etc
1084 ./bin
8 ./root
4 ./home
42024 ./app
411300 .
[EDIT]
Using dive, I was able to see that the bloat is coming from a COPY
command that does increase in size (the tmp/ folder), but I have a specific command to rm -rf tmp
to reclaim that space.
It appears the COPY
is caching the size?
The final image size remains even though I am deleting the thing that causes the size difference?
COPY showing tmp/ w/ bloatRUN rm -rf tmp
to remove bloat