Scripts2026年4月16日·1 分钟阅读

ctop — Top-Like Interface for Container Metrics

Real-time monitoring dashboard for Docker and runC containers, displaying CPU, memory, network, and I/O metrics in a familiar top-style terminal UI.

Introduction

ctop brings the simplicity of Unix top to running containers. Instead of juggling docker stats output or navigating complex dashboards, ctop gives you a single real-time terminal view of every container's resource usage on the host.

What ctop Does

  • Displays live CPU, memory, network I/O, and disk I/O per container
  • Supports both Docker and runC container runtimes
  • Provides a single-container detailed view with historical sparkline graphs
  • Allows sorting, filtering, and searching containers interactively
  • Offers start, stop, pause, and remove actions directly from the TUI

Architecture Overview

ctop is a single Go binary that connects to the Docker daemon socket (or runC state directory) to poll container stats at a configurable interval. It renders output using the termui library, presenting a scrollable table with per-container rows and a drill-down detail panel for individual containers.

Self-Hosting & Configuration

  • No server component needed — runs as a standalone CLI binary
  • Configure Docker endpoint via DOCKER_HOST environment variable
  • Set default sort column and refresh interval in ~/.ctop YAML config
  • Supports remote Docker hosts over TCP or SSH tunnels
  • Container logs are viewable inline without leaving the interface

Key Features

  • Zero-dependency single binary — download and run, no Python or Node required
  • Real-time sparkline graphs for CPU and memory trends over time
  • Built-in container management: start, stop, restart, pause, remove
  • Keyboard-driven navigation with vim-style keybindings
  • Works with Docker Desktop, Docker Engine, and runC out of the box

Comparison with Similar Tools

  • docker stats — plain text table, no sorting or filtering, no actions
  • Lazydocker — broader Docker management (images, volumes) but heavier
  • Portainer — full web UI for Docker management, requires deployment
  • cAdvisor — exports container metrics for Prometheus, no interactive TUI
  • Dry — similar TUI but fewer real-time graphing features

FAQ

Q: Does ctop work with Podman? A: Not natively. ctop targets the Docker and runC APIs. For Podman you can enable the Docker-compatible socket and point DOCKER_HOST to it.

Q: Can I monitor containers on a remote host? A: Yes. Set DOCKER_HOST=tcp://remote:2376 or use SSH forwarding to the remote Docker socket.

Q: How much overhead does ctop add? A: Negligible. It polls the same stats API that docker stats uses, consuming under 10 MB of RAM.

Q: Does ctop support Kubernetes pods? A: No. ctop monitors containers on a single host. For Kubernetes cluster monitoring, use tools like k9s or Lens.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产