Skip to main content

Clean to Execute

clean-to-execute removes Docker Compose resources for a local clone of a GitHub repository.

The repository is found recursively by inspecting Git remotes under the user's home directory. Directory names alone are not trusted. Docker Compose files must be at the repository root.

Requirements

  • Python 3.10 or newer
  • Git
  • Docker with the Compose plugin
  • Access to a running Docker daemon

Installation

From this directory:

python3 -m pip install .

Usage

Execute cleanup:

clean-to-execute --repository example

Preview cleanup without changing Docker resources:

clean-to-execute --repository example --dry-run

Search somewhere other than ~:

clean-to-execute \
  --repository example \
  --root /workspaces

The GitHub organization defaults to kaizten. Use --organization to select a different organization.

Cleanup is destructive by default. Use --dry-run when only a preview is required.

Before cleanup, each published host port is annotated with the PID and name of its current host listener when that information is available. PID discovery is best-effort and uses the Linux ss command. An unbound port is shown as not listening; missing tools or insufficient permissions are shown as PID unavailable and do not prevent cleanup.

Cleanup scope

The command recognizes compose.yaml, compose.yml, docker-compose.yaml, and docker-compose.yml at the repository root. Docker Compose renders the effective configuration, including its normal override and environment interpolation behavior. All Compose profiles are activated for inspection and shutdown, so services and ports behind profiles are included without requiring the caller to name each profile.

By default, the command:

  1. Stops and removes the entire Compose project, including orphan containers, so all of its published ports are released.
  2. Deletes the project's non-external named and anonymous volumes.
  3. Deletes all other dangling Docker volumes, while preserving external volumes declared by this Compose project.
  4. Force-removes local images referenced by the Compose configuration whose namespace matches the GitHub organization.

The namespace comparison works across registries. For example, all of these belong to the GitHub organization kaizten:

  • kaizten/api
  • docker.io/kaizten/api
  • ghcr.io/kaizten/api
  • registry.example.com/kaizten/api

Containers outside the selected Compose project are never stopped or removed. An external container may still prevent Docker from deleting an image; that is reported as a cleanup failure.

If multiple local clones match the same GitHub remote, the command lists them and exits instead of choosing one implicitly.

Development

python3 -m unittest discover -s tests -v
./build-package.sh

Metadata

Release files for clean-to-execute 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for clean-to-execute 0.0.2
File Size Uploaded
clean_to_execute-0.0.2.tar.gz 11.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for clean-to-execute 0.0.2
File Interpreter ABI Platform
clean_to_execute-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 20.4 kB

Release files / clean_to_execute-0.0.2.tar.gz

Download URL clean_to_execute-0.0.2.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
02ba5f85636005277736e882ec9c61bcc9a65b0ad7f54fd5eded8a0084760b93
BLAKE2b-256 checksum
How to use checksums
d99d4d9d713ea6dc5c4ea73ad2082e1093420cc1258b0b3ba4131768c3cadecc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / clean_to_execute-0.0.2-py3-none-any.whl

Download URL clean_to_execute-0.0.2-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4c7a3ca5fb3f25b338a7ae018ec5a53b2e38ce74f70b6f51fa6b814fc57ba30c
BLAKE2b-256 checksum
How to use checksums
2238554d67428a53ff4ff696b59f2d6c9b4ef8d1a871939b5977b9be5e6d42f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page