docker-squash is a Python utility that reduces Docker image sizes by combining multiple layers into one. It retains Dockerfile metadata such as `PORT` and `ENV` instructions, which the native `docker build --squash` command often discards. The project is actively maintained with regular updates, currently at version 1.2.2.
pip install docker-squashVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to pull a base Ubuntu image and then use `docker-squash` to squash its layers into a new image tagged `ubuntu:squashed`. The final command lists Docker images, allowing you to compare the original and squashed image sizes.
Upgrade to Python 3.6 or newer. The current version requires Python 3.6+.
Ensure your installed `docker` Python package version is compatible with your `docker-squash` version. Refer to the `docker-squash` changelog or PyPI dependencies for the specific range supported by your version.
Upgrade to `docker-squash` version 1.2.2 or newer, where this bug was fixed.
Upgrade `docker-squash` to version 1.2.0 or newer to ensure compatibility with Docker 25+ OCI archive format.