docker-squash
Docker layer squashing tool
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-squashuv
uv add docker-squashpoetry
poetry add docker-squashInstalling 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
More Build Tools packages
Provides reusable utilities for Python…
permissive · top 100 on PyPI
tqdmWraps any iterable to display a real-time…
copyleft · top 100 on PyPI
pippip is the standard installer for Python…
permissive · top 100 on PyPI
hatchlingHatchling is a standards-compliant Python build…
permissive · top 100 on PyPI
grpcio-toolsGenerates Python gRPC service stubs and message…
permissive · top 1,000 on PyPI
pre-commitpre-commit is a framework for installing and…
permissive · top 1,000 on PyPI
container-inspectorAnalyzes Docker images, containers, and virtual…
permissive · top 15,000 on PyPI
nvidia-modeloptApplies state-of-the-art model optimization…
permissive · top 15,000 on PyPI
tf-slimTensorFlow-Slim provides high-level layers,…
permissive · top 15,000 on PyPI
psd-toolspsd-tools reads and writes Adobe Photoshop…
permissive · top 15,000 on PyPI
azure-containerregistryClient library for managing container images,…
permissive · top 5,000 on PyPI
lib-layered-configLoads and merges configuration from multiple…
permissive · top 15,000 on PyPI
blend-modesImplements blend modes (soft light, dodge,…
permissive · top 15,000 on PyPI
model-compression-toolkitCompresses and optimizes neural networks…
permissive · top 15,000 on PyPI
binpackingDistributes weighted items into bins using…
permissive · top 15,000 on PyPI
tox-dockerA tox plugin that manages Docker container…
permissive · top 15,000 on PyPI