skillfed

docker-squash

Docker layer squashing tool

docker-squash v1.2.2 113.8K downloads/30d#12,328 on PyPI958
Permissive license MIT AGING released

What it is and what it does

docker-squash is a command-line tool that merges multiple layers in a Docker image into fewer layers. Docker builds create many intermediate layers, some of which may contain temporary files that are deleted in later layers—these unnecessary layers bloat the final image. The tool lets you squash the last N layers, or all layers from a specified layer onward, reducing image size and improving push/load performance.

The tool works by extracting the image, combining the target layers into a single tar archive, and either loading the result back into the Docker daemon or saving it as a tar file. It depends on the docker and packaging libraries and runs as a CLI utility rather than as an importable module.

Use it for:

  • Reduce final image size after a multi-stage build by squashing temporary build artifacts into a single layer.
  • Optimize images for faster push to a registry by consolidating many small metadata layers.
  • Simplify image history for cleaner layer inspection and easier debugging of production images.
  • Prepare images for distribution where layer count matters (e.g., embedded or resource-constrained environments).
  • Consolidate base image layers with application layers to reduce the number of independent components.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Combines multiple Docker image layers into fewer layers to reduce image size and push/load time, controllable by layer count or starting layer ID.

Yes, if you actively manage Docker images and want to reduce their size and push time. The tool is straightforward and has no known vulnerabilities. However, the aging maintenance status (last release 639 days ago) and high install friction (source distribution, Docker daemon requirement) mean you should verify compatibility with your Docker version before relying on it in production workflows. For one-off optimization tasks, it's low risk; for frequent automation, consider whether a more actively maintained alternative exists.

Install

docker-squash on PyPI

pip

pip install docker-squash

uv

uv add docker-squash

poetry

poetry add docker-squash

Installing docker-squash

Before you install

High install friction due to a source distribution and direct Docker daemon dependency. Maintenance status is aging—last release was 639 days ago, though the repository remains active with recent commits and moderate GitHub stars (958).

License in practice

MIT license is permissive and imposes no restrictions on use, modification, or distribution.

Quickstart

pip install docker-squash
docker-squash -f <layer-id-or-count> -t <new-tag> <image-name>

Requires a running Docker daemon and Docker CLI to be installed on the system; the package itself is a CLI tool, not a library for programmatic use.

Verify before relying

  • Whether the package works reliably with current Docker versions beyond 1.9
  • Whether Python version support has changed since the description mentions 3.6+
  • Whether the tool handles modern image formats (e.g., OCI) or only Docker v1/v2 formats

Package facts

License MIT (permissive)
Python support not specified
Install friction high — source build required
Runtime dependencies 2 — docker, packaging
Maintenance aging — 639 days since the last release
Last repo commit
First released
Downloads 113,839/month — #12,328 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: docker_squash-1.2.2.tar.gz

Keywords: docker

Tags

docker layer squashingreduce docker image sizecombine docker layersdocker image optimizationdocker layer consolidationminimize docker imagedocker build optimization
docker-optimizationcli-toolimage-management

More Build Tools packages