Troubleshoot suspiciously big docker images

francoislp

François

Posted on November 8, 2023

Troubleshoot suspiciously big docker images

Yesterday, I was working on deploying features/PRs environments on the fly for a multi-tenancy Laravel app. To help me with this task where I had to jump between code, YAML files, and docker files, I used skaffold which is great to package all the standard steps "build, push, deploy" into one simple: skaffold dev

At one point I ran out of disk space so I decided to give a look at my docker images, to my dismay, I saw the php-fpm docker image was 3.67 GB big.

Let me introduce you to a beautiful tool called dive.

This tool lets you track layer by layer what is taking disk space in your docker image. It is so good, thanks to it I've found a residual 900 Mb Laradock folder imported twice in the docker image.

It makes it super easy to inspect what folders/files you could add to your .dockerignore that you may have forgotten.

│ Image Details ├───────────────────────────────────

Image name: r******g/***fpm***:468xcbb5-dirty
Total Image size: 614.04 MB
Potential wasted space: 2.8 MB
Image efficiency score: 99 %
Enter fullscreen mode Exit fullscreen mode

They even have a CI option!

💖 💪 🙅 🚩
francoislp
François

Posted on November 8, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related