๐ ๏ธ Simple and interactive CLI for Docker container management
Project description
Docker Tool
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:
- Exact ID match: Full container ID
- ID prefix: Beginning of container ID
- Exact name: Full container name
- 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.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - 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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bfe9b5bcbdcb45300c5983dbc0c569ff8660c59814974aa4b09ca3508d123d2
|
|
| MD5 |
e0e0f3102eb52888f358595bed50990a
|
|
| BLAKE2b-256 |
0b41526a013f351e80ad6cce01932d2a87c7302b364538706cde7cb044f11b00
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14aadb1cafa7c1f945a7412e4d7beab2c844e0f80aa2e4e928d11c634a3259b4
|
|
| MD5 |
a945cc34d2727a0212136d802ba09640
|
|
| BLAKE2b-256 |
2a6cff7af2178c61fb1fa8ce99216d2cb1fae660e77d97b2258fc51ed8e774e2
|