Skip to main content

🛠️ Simple and interactive CLI for Docker container management

Project description

Docker Tool

🐳 Smart Docker container management with an elegant CLI.

Features

  • 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 Compose Support: Automatically detects and uses docker-compose

Installation

Prerequisites

  • Python 3.8+
  • Docker installed and running

Install

git clone <your-repo>
cd docker-tool

pip install -r requirements.txt

chmod +x docker_tool.py

sudo ln -s $(pwd)/docker_tool.py /usr/local/bin/dtool

Usage

Quick Commands

List Containers

# List running containers
dtool ps

# List all containers
dtool ps -a

# Interactive container selection
dtool ps -i

Container Management

# Open shell (intelligent container search)
dtool shell nginx
dtool shell backend
dtool shell e5d  # Partial ID

# Execute commands
dtool exec nginx ls -la
dtool exec backend cat /etc/hosts

# View logs
dtool logs nginx
dtool logs backend -f

# Container lifecycle
dtool stop nginx
dtool start nginx
dtool restart backend
dtool rm nginx
dtool rm backend -f

Smart Container Search

The tool intelligently searches for containers:

  1. By ID: Matches container ID prefix

    dtool shell e5d4a2  # Matches container starting with e5d4a2
    
  2. By exact name: Matches full container name

    dtool shell my-nginx  # Matches container named "my-nginx"
    
  3. By partial name: Grep-like search

    dtool shell backend  # Matches "app-backend", "backend-api", etc.
    
  4. Interactive selection: When multiple matches found

    dtool shell app  # Shows menu if multiple containers contain "app"
    

Examples

Common Workflows

# Quick shell access
dtool shell backend

# Check logs of multiple services
dtool logs frontend --tail 20
dtool logs backend --tail 20

# Restart a service
dtool restart nginx

# Interactive management
dtool wizard

Advanced Usage

# Use specific shell
dtool shell alpine --shell /bin/sh

# Force stop container
dtool stop stubborn-container --force

# Follow logs with custom tail
dtool logs app --tail 200 --follow

Project Structure

docker-tool/
├── docker_tool.py       # Main entry point
├── requirements.txt     # Python dependencies
├── README.md           # This file
└── lib/
    ├── __init__.py
    ├── docker_client.py # Docker command wrapper
    └── version.py       # Version information

Why Docker Tool?

  • Shorter Commands: dtool shell nginx vs docker exec -it nginx /bin/bash
  • Smart Search: No need to remember full container IDs or names
  • Beautiful Output: Rich formatting makes information easy to read
  • Interactive Mode: Perfect for when you're not sure what you want to do
  • Error Handling: Graceful fallbacks (e.g., sh when bash unavailable)

Contributing

Feel free to submit issues and enhancement requests!

License

MIT License - feel free to use in your projects!

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.0.tar.gz (8.8 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.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for docker_tool-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ea943f762f96877260adb594fb34aff0b3c048ab2d8767bf248308d9d5a577eb
MD5 e7a01c0f962be1449f08371e08eeb3e3
BLAKE2b-256 d7c790316f2b637bbd53de2e1a4a2ea6cc38b901b744f49005c9ace821c087f8

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for docker_tool-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b3375d6022a5b50bc9e7f1019827ac39099c18365d9147b9400f1cbe98da525
MD5 ad8c642520d035bd3023a3125adcee49
BLAKE2b-256 4d95e9aa19f93ec815833eb21f624fa21a76d557e87e93824ff0a820ba80f85e

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