Skip to main content

CLI tool for managing Docker container cleanups

Project description

Docker Tools Plus

PyPI version

A command-line tool for managing Docker container cleanups using predefined regular expression patterns.

Features

  • ๐Ÿณ Create named cleanup configurations with regular expressions
  • ๐Ÿ—‘๏ธ Clean containers, volumes, and images matching patterns
  • ๐Ÿ’พ SQLite database for persistent configuration storage
  • ๐Ÿ” Interactive prompts for multiple matches
  • ๐Ÿ›ก๏ธ Safety confirmations before destructive operations

Installation

  1. Install using uv:
uv pip install git+https://github.com/yourusername/docker-tools-plus.git
  1. Verify installation:
docker-tools-plus --help

Usage

Create and Execute Cleanup

docker-tools-plus clean <name> [--force]
  • Use --force to skip all confirmation prompts
  • Automatically cleans all resource types without asking

Example flow without --force:

$ docker-tools-plus clean reconciliation
No cleanup found matching 'reconciliation'
Please enter a regular expression: reconciliation[a-z_]*_postgres

Created new cleanup config:
ID: 1 | Name: reconciliation | Pattern: reconciliation[a-z_]*_postgres

Clean containers? [Y/n]: y
Clean volumes? [Y/n]: y
Clean images? [Y/n]: y

Example with --force:

$ docker-tools-plus clean reconciliation --force
Created new cleanup config:
ID: 1 | Name: reconciliation | Pattern: reconciliation[a-z_]*_postgres
Cleaning containers... done
Cleaning volumes... done
Cleaning images... done

List All Cleanups

docker-tools-plus list

Output:

1: reconciliation - reconciliation[a-z_]*_postgres
2: temp-containers - temp_.+

Delete a Cleanup

docker-tools-plus delete <name>

Example:

$ docker-tools-plus delete temp
Multiple matches found:
1: temp-containers
2: temp-images
Enter the ID to delete: 1
Delete cleanup 'temp-containers' (ID: 1)? [y/N]: y

Show Info

docker-tools-plus about

Displays application information in a formatted panel with:

  • Application name and version (centered)
  • Database location with file existence indicator (โœ“ if exists, โœ— if missing)
  • Description

Example panel:

โ”Œ About โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                                                          โ”‚
โ”‚             docker-tools v0.4.2                          โ”‚
โ”‚                                                          โ”‚
โ”‚  Database location: /path/to/cleanups.db โœ“               โ”‚
โ”‚                                                          โ”‚
โ”‚  CLI tool for managing Docker container cleanups          โ”‚
โ”‚                                                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Reset Database

docker-tools-plus reset

Creates a timestamped backup of the current database and creates a new blank one. Requires confirmation unless --force is used.

Example:

$ docker-tools-plus reset
This will rename your current database and create a new blank one. Continue? [y/N]: y
Renamed existing database to cleanups_20240614_123456.db
Created new blank database successfully.

Configuration

Create configuration.toml to customize:

[database]
path = "custom_cleanups.db"

Development

# Install dev dependencies
uv pip install -e '.[dev]'


# Run tests
make test

# Generate coverage report
make cov

# Lint code
make lint

Database Management

The default application path is ~/.config/docker-tools-plus/.

This path will probably not work on Windows, so you can specify a custom path in configuration.toml:

The SQLite database is automatically created at:

  • Default: docker_tools_plus.db
  • Custom: Path specified in configuration.toml

Safety Features

  1. Confirmation Prompts for destructive operations
    • Always asks before cleaning each resource type (containers/volumes/images)
    • Can be skipped with --force option
  2. Separate Resource Types (containers/volumes/images)
  3. Force Mode (use with caution):
    • Skips all confirmation prompts
    • Automatically cleans all resource types
    • Requires explicit --force flag:
docker-tools-plus clean <name> --force

โš ๏ธ Warning: Regular expressions are powerful - test patterns with docker ps -a/docker volume ls/docker image ls before creating cleanup configurations.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docker_tools_plus-0.5.1.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docker_tools_plus-0.5.1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file docker_tools_plus-0.5.1.tar.gz.

File metadata

  • Download URL: docker_tools_plus-0.5.1.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for docker_tools_plus-0.5.1.tar.gz
Algorithm Hash digest
SHA256 2dba7e779ff60c34a0e9be1d7be39e1b0579ad0580fbb5136c57f5dae3223e9c
MD5 df82bfc3889f58050a5fb70b1a9eca57
BLAKE2b-256 282b7ee435f8a81e6f778b8930779d3eed4dc5aea0e99adfd79140365fac72ec

See more details on using hashes here.

File details

Details for the file docker_tools_plus-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for docker_tools_plus-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3b97d2ae5970cf1eacdce56baf633abfd523f9453db2e02516df3628479758fc
MD5 9dba2ecb8b59f1269599b7c74369cd3e
BLAKE2b-256 77535bcd238845f40084ea34dcf9ccef2b74b4b97de0a133b52f18f2cf02bedc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page