Skip to main content

๐Ÿ› ๏ธ Simple and interactive CLI for Docker container management

Project description

Docker Tool

Docker Python MIT License

Smart Docker container management with an elegant CLI

Features โ€ข Installation โ€ข Quick Start โ€ข Documentation โ€ข Contributing


Features

Core Features

  • Interactive Wizard Mode: Beautiful TUI for container management
  • Smart Container Search: Find containers by ID, name, or partial match
  • Rich Output: Colorful tables and formatted output with rich
  • Intelligent Commands: Short commands that do what you expect
  • Docker API Integration: Direct Docker SDK usage for better performance
  • Smart Error Handling: User-friendly error messages and suggestions

Advanced Features

  • Container Status Indicators: Visual status in wizard mode
  • Auto-Detection: Automatically detects Docker/Docker Compose
  • Shell Completion: Tab completion for commands (bash, zsh, fish)
  • Regex Filtering: Advanced container filtering with regex support

Installation

Prerequisites

  • Python 3.8+
  • Docker installed and running
  • pip package manager

Install from PyPI

pip install docker-tool

Install from Source

# Clone the repository
git clone https://github.com/julestblt/docker-wrapper.git
cd docker-wrapper

# Install in development mode
pip install -e .

Enable Shell Completion

# Bash
dtool --install-completion bash

# Zsh
dtool --install-completion zsh

# Fish
dtool --install-completion fish

Quick Start

Interactive Wizard Mode

The easiest way to manage containers:

# Launch the interactive wizard
dtool wizard

Features:

  • Visual container selection with status indicators
  • Context-aware actions based on container state
  • Beautiful prompts with questionary
  • Navigate with arrow keys, select with Enter

List Containers

# List running containers
dtool ps

# List all containers (including stopped)
dtool ps -a

# Interactive mode - select and manage containers
dtool ps -i

# Filter containers by name/ID
dtool ps nginx
dtool ps e5d

# Use regex filtering
dtool ps "^web-.*" -r

Documentation

Container Management Commands

Shell Access

# Quick shell access (auto-detects bash/sh)
dtool shell nginx
dtool shell backend
dtool shell e5d  # Partial ID works!

# Use specific shell
dtool shell alpine /bin/sh
dtool shell ubuntu /bin/zsh

Execute Commands

# Run single commands
dtool exec nginx "ls -la"
dtool exec backend cat /etc/hosts
dtool exec web "ps aux | grep node"

View Logs

# View last 100 lines (default)
dtool logs nginx

# Follow logs in real-time
dtool logs backend -f
dtool logs backend --follow

# View specific number of lines
dtool logs app --tail 50

Container Lifecycle

# Start containers
dtool start nginx
dtool start backend frontend db  # Multiple containers

# Stop containers
dtool stop nginx
dtool stop backend --force  # Force stop

# Restart containers
dtool restart nginx
dtool restart backend --force

# Remove containers
dtool rm old-container
dtool rm test-app --force  # Force remove running container

Smart Container Search

The tool intelligently searches for containers in this order:

  1. Exact ID match: Full container ID
  2. ID prefix: Beginning of container ID
  3. Exact name: Full container name
  4. Partial match: Grep-like search in names
# Examples
dtool shell e5d4a2b1          # ID prefix
dtool shell nginx              # Exact name
dtool shell backend            # Matches: my-backend, backend-api, etc.
dtool logs "web|api" -r        # Regex: matches web OR api

Advanced Usage

Filter and Manage

# List only Redis containers
dtool ps redis

# Stop all containers matching pattern
dtool ps "test-" -r | xargs -I {} dtool stop {}

# View logs of all API containers
dtool ps "api" | xargs -I {} dtool logs {} --tail 20

Error Handling Examples

The tool provides helpful error messages:

$ dtool shell nonexistent
โ•ญโ”€ Container Error โ”€โ•ฎ
โ”‚ Container not found! โ”‚
โ”‚                      โ”‚
โ”‚ No container with    โ”‚
โ”‚ name or ID           โ”‚
โ”‚ 'nonexistent' was    โ”‚
โ”‚ found.               โ”‚
โ”‚                      โ”‚
โ”‚ Try running:         โ”‚
โ”‚ โ€ข dtool ps -a        โ”‚
โ”‚ โ€ข dtool ps           โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Project Structure

docker-tool/
โ”œโ”€โ”€ docker_tool/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ cli.py           # Main CLI entry point
โ”‚   โ”œโ”€โ”€ docker_client.py # Docker SDK wrapper
โ”‚   โ”œโ”€โ”€ wizard.py        # Interactive wizard mode
โ”‚   โ”œโ”€โ”€ utils.py         # Utility functions
โ”‚   โ””โ”€โ”€ version.py       # Version information
โ”œโ”€โ”€ requirements.txt     # Python dependencies
โ”œโ”€โ”€ setup.py            # Package configuration
โ””โ”€โ”€ README.md           # This file

Why Docker Tool?

Feature Docker CLI Docker Tool
Open shell docker exec -it nginx /bin/bash dtool shell nginx
View logs docker logs -f --tail 100 nginx dtool logs nginx -f
Stop container docker stop nginx dtool stop nginx
Interactive mode Not available dtool wizard
Smart search Exact ID/name required Partial match, regex
Error messages Technical errors User-friendly guidance

Development

Setup Development Environment

# Clone the repo
git clone https://github.com/yourusername/docker-tool.git
cd docker-tool

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install in development mode
pip install -e .

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Code Style

  • Follow PEP 8
  • Use type hints
  • Add docstrings to functions

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Built with Typer - The amazing CLI framework
  • Styled with Rich - Beautiful terminal formatting
  • Interactive mode powered by Questionary
  • Docker SDK for Python

Made with love by developers who hate long Docker commands

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_tool-1.0.3.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

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

docker_tool-1.0.3-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file docker_tool-1.0.3.tar.gz.

File metadata

  • Download URL: docker_tool-1.0.3.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for docker_tool-1.0.3.tar.gz
Algorithm Hash digest
SHA256 3bfe9b5bcbdcb45300c5983dbc0c569ff8660c59814974aa4b09ca3508d123d2
MD5 e0e0f3102eb52888f358595bed50990a
BLAKE2b-256 0b41526a013f351e80ad6cce01932d2a87c7302b364538706cde7cb044f11b00

See more details on using hashes here.

File details

Details for the file docker_tool-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: docker_tool-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for docker_tool-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 14aadb1cafa7c1f945a7412e4d7beab2c844e0f80aa2e4e928d11c634a3259b4
MD5 a945cc34d2727a0212136d802ba09640
BLAKE2b-256 2a6cff7af2178c61fb1fa8ce99216d2cb1fae660e77d97b2258fc51ed8e774e2

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