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.0.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.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: docker_tools_plus-0.5.0.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.0.tar.gz
Algorithm Hash digest
SHA256 902d651384cfa893e25e32d7511970444d0556fd4f75163b7cfaf2039be91d8e
MD5 28394a8135844fb47dcc6031318eaa2e
BLAKE2b-256 481ff21b17badba2cbef635df9236b09e9dacf95dfeb1a6fe178b5a9552f2b0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for docker_tools_plus-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4826c291e209b79cc95def4caee44bd15012fd663d1ddafc7c3dc9087f7b0050
MD5 9048ae2922053db219a7c3b92da6e346
BLAKE2b-256 f708f5d2707a673aa1821678a1ea8d0dbab411c84f1819f21df7773ad49a42a4

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