dtop

command module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2025 License: MIT Imports: 8 Imported by: 0

README

dtop - Docker Container Monitor

A terminal UI tool for monitoring Docker containers, inspired by htop. Displays containers grouped by project with an interactive tree interface.

dtop screenshot

Features

  • Project Grouping: Automatically groups containers by their name prefix (Docker Compose convention)
  • Tree Navigation: Expandable/collapsible project view
  • Real-time Monitoring: Auto-refreshes container status every 2 seconds
  • Interactive Actions: Context-aware menu system for managing containers
  • Keyboard-driven: Full keyboard navigation with vim-style keybindings
  • Viewport Scrolling: Efficient handling of hundreds of containers with automatic scrolling
  • Sticky Footer: Help text always visible at bottom of screen
  • Scroll Indicator: Shows current position when content exceeds screen height
  • List Mode: Non-interactive output for scripts and CI/CD pipelines (--list / -l)
  • Visual Progress Bars: CPU and memory usage displayed with inline bar graphs
  • Network Monitoring: Real-time network I/O stats (RX/TX) for each container

Installation

go install github.com/ekinertac/dtop@latest

This installs dtop to your $GOPATH/bin directory (usually ~/go/bin).

If the command is not found after installation, add Go's bin directory to your PATH:

# For bash/zsh, add to ~/.bashrc or ~/.zshrc
export PATH="$PATH:$(go env GOPATH)/bin"

# Or if go command is not available, typically it's:
export PATH="$PATH:$HOME/go/bin"

After adding the export line, restart your terminal or run source ~/.bashrc (or ~/.zshrc).

From source
git clone https://github.com/ekinertac/dtop.git
cd dtop
go build -o dtop

Usage

Interactive mode (default)
dtop

Launches the full interactive TUI with real-time monitoring and keyboard navigation.

List mode (non-interactive)
dtop --list
# or short form
dtop -l

Lists current containers and exits immediately. Useful for:

  • Shell scripts and automation
  • CI/CD pipelines
  • Quick status checks in non-interactive environments
  • Logging/monitoring systems

Example output:

dtop - Docker Container Monitor

NAME                                     STATUS                    CPU          MEMORY       NET RX/TX      UPTIME
----------------------------------------------------------------------------------------------------------------------------------
▼ myproject (3)
    myproject-web-1                      Up 2 hours                 33% ████░    12% █░░░░   1.2M/450K      02h 15m
    myproject-db-1                       Up 2 hours (healthy)        8% █░░░░     5% ░░░░░   621B/566B      02h 15m
    myproject-worker-1                   Up 2 hours                  2% ░░░░░     3% ░░░░░   1.4K/890B      02h 15m

Keyboard Shortcuts

Navigation
  • / k - Move up
  • / j - Move down
  • PgUp - Page up
  • PgDn - Page down
  • Home - Jump to top
  • End - Jump to bottom
  • / h - Collapse project
  • / l - Expand project
  • Enter - Open action menu
  • q / Ctrl+C - Quit
Menu Navigation
  • / - Select menu item
  • Enter - Execute action
  • Esc - Close menu

Actions

Project-level Actions
  • Restart All - Restart all containers (docker compose restart)
  • Stop All - Stop all running containers (docker compose stop)
  • Down - Stop and remove all containers (docker compose down, keeps volumes)
  • Start All - Start all stopped containers (docker compose start)
Container-level Actions
  • Restart - Restart the container (docker restart)
  • Stop - Stop the container (docker stop)
  • Remove - Remove the container (docker rm, keeps volumes)
  • Logs - View container logs (last 1000 lines, scrollable)

Note: All operations preserve volumes by default. To remove volumes, use docker volume rm or docker compose down --volumes from the terminal.

How It Works

Project Grouping: dtop automatically groups containers based on their naming convention:

  • myproject_web_1 → project: myproject
  • myproject-db-1 → project: myproject
  • Standalone containers are shown under their own project name

Docker Integration: Uses Docker API directly for all operations, no docker-compose dependency required.

Requirements

  • Go 1.21+
  • Docker running on local machine
  • Docker socket accessible (typically /var/run/docker.sock)

Development

# Install dependencies
go mod download

# Build
go build

# Run
./dtop

Publishing to GitHub

To make your tool available via go install, push to GitHub:

# Initialize git if not already done
git init
git add .
git commit -m "Initial commit"

# Create repo on GitHub, then:
git remote add origin https://github.com/ekinertac/dtop.git
git branch -M main
git push -u origin main

# Create a release tag (optional, for versioning)
git tag v0.1.0
git push origin v0.1.0

After pushing, others can install with:

go install github.com/ekinertac/dtop@latest

Use Cases

Interactive monitoring:

dtop

Monitor containers in real-time with keyboard control.

Scripts and automation:

# Check container status
dtop --list
# or
dtop -l

# Save to file
dtop -l > containers.txt

# Pipe to other tools
dtop -l | grep "myproject"

# CI/CD health check
if dtop -l | grep -q "Exit"; then
    echo "Some containers are down!"
    exit 1
fi

Roadmap

  • List mode for non-interactive use (--list / -l)
  • Real-time CPU/Memory statistics with progress bars
  • Network I/O monitoring (RX/TX per container)
  • Log viewer with scrolling
  • Container inspect view
  • Exec into container
  • Filter/search functionality
  • Color themes
  • Configuration file support

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL