Registry / devops / docker-squash

docker-squash

JSON →
library1.2.2pypypiunverified

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-squash
INSTALL
IMPORT
SIG · DOCKER-SQUASH
D
docker-squash
devopspythonv1.2.2
Install
3.3s avg
Import
—
Disk
23MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.2.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 24.8MB
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 3.3s · import 0.000s · 25MB
23MB installed
● package 23MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

docker-squash
✓ This library is primarily a command-line interface (CLI) tool. It is typically invoked directly from the shell rather than imported and used programmatically in Python code.
✗ from docker_squash import Squash
While there's internal Python code, the public-facing and documented usage is via the 'docker-squash' CLI command. Direct programmatic import is not officially supported or commonly practiced.

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.

docker pull ubuntu:latest docker-squash -t ubuntu:squashed ubuntu:latest docker images | grep 'ubuntu'
docker-squash --version
Debug
Known issues
breakingSupport for Python 2.7 and Python 3.5 was dropped in `docker-squash` version 1.1.0.
fix
Upgrade to Python 3.6 or newer. The current version requires Python 3.6+.
affects: <1.1.0
gotchaThe `docker-squash` utility has had varying compatibility requirements with the underlying Docker Python client library (PyPI package `docker`). Earlier versions (e.g., 1.0.7) pinned the client to `<3` due to performance issues, while later versions (e.g., 1.0.10) added support for `>=6.0.0`.
fix
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.
affects: All versions, especially around 1.0.x
gotchaVersion 1.2.1 introduced a regression that prevented the `-f` (from-layer) flag from working correctly. This caused squashing operations using this flag to fail.
fix
Upgrade to `docker-squash` version 1.2.2 or newer, where this bug was fixed.
affects: 1.2.1
gotchaOlder versions of `docker-squash` (prior to 1.2.0) were incompatible with Docker daemon versions 25 and newer, due to Docker 25 switching to the OCI archive format. This could lead to errors like 'No such file or directory: 'scratch/old/blobs/layer.tar''.
fix
Upgrade `docker-squash` to version 1.2.0 or newer to ensure compatibility with Docker 25+ OCI archive format.
affects: <1.2.0
Upgrade
Version history
1.2.2latest on PyPI · released Nov 13, 2024
Audit
Dependencies
dockerrequiredRequired for interacting with the Docker daemon and performing image operations.
Agent activity
51 hits · last 30 days
node
46
OpenAI (training)
1
Resources
docker-squash — pip install docker-squash · libregistry