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
dtool logs backend

# Restart a service
dtool restart nginx

Advanced Usage

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

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

# Follow logs
dtool logs app -f

Project Structure

docker-wrapper/
├── requirements.txt     # Python dependencies
└── docker_tool/
    ├── __init__.py
    ├── cli.py           # Main CLI entry point
    ├── docker_client.py # Docker command wrapper
    ├── version.py       # Version information
    └── utils.py         # Utility functions

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: docker_tool-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 dfaa8f210b99432970196f84b49df31a9e1c9b9f52ae46964b85f5c443e24590
MD5 439a8e08a2283c09a766973bd79afcb7
BLAKE2b-256 6561849d2b7ef98b499a488ffbc06f07b4e4d955167ac15b6793d88c8e0319a2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: docker_tool-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b086c8a13a03cb356df327762b686a903e71993130b0eea54ce98522fe38d69a
MD5 e76e3d5f04519fd0bd8d0b5f42a996f9
BLAKE2b-256 a43e37b589b9e5b02412a7291d3d81c4a4f5671ab481c0e8f8f412987e2b4026

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