Docker images tend to become bigger very quickly.

You can reduce the image size squashing the image. There are several utilities to squash an image, we will use

Use the following commands to download and extract the utility:

sudo tar -C /usr/local/bin -xzvf docker-squash-linux-amd64-v0.2.0.tar.gz

One you have copied docker-squash you can piping your commands as described below (note that you can fork any shell command after the docker load):

docker save 75e2c7769b | ./docker-squash -from root -t repositoryId | docker load & <your_forked_command>

All parameters are self explanatory except -from root. If you don’t use this parameter the base image (FROM statement) is kept separately as seen in the circle pointed by the first arrow in the image below. If you use it then the FROM statement is also squashed as seen in the circle pointed by the second arrow.


Note that Image IDs are different/unique even though they’re both based on the same image.

Javier Andrés Cáceres Alvis

Microsoft Most Valuable Professional – MVP

Intel Black Belt Software Developer