ctop: A Top-Like Interface for Container Metrics¶
Introduction¶
ctop is a command-line tool that provides a real-time, condensed view of metrics for Docker containers. Inspired by the top utility, ctop allows users to monitor resource usage, manage containers, and gain insights into container performance directly from the terminal. It supports Docker and runC, with plans for connectors to other container systems.
Installation¶
ctop can be installed using various methods, depending on the operating system.
-
Debian/Ubuntu:
* Arch:sudo apt-get install ca-certificates curl gnupg lsb-release curl -fsSL https://azlux.fr/repo.gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/azlux-archive-keyring.gpg echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/azlux-archive-keyring.gpg] http://packages.azlux.fr/debian \ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/azlux.list > /dev/null sudo apt-get update sudo apt-get install docker-ctopctopis available in the AUR. * Linux (Generic):* OS X:sudo wget https://github.com/bcicen/ctop/releases/download/v0.7.7/ctop-0.7.7-linux-amd64 -O /usr/local/bin/ctop sudo chmod +x /usr/local/bin/ctopor
or
* Windows:sudo curl -Lo /usr/local/bin/ctop https://github.com/bcicen/ctop/releases/download/v0.7.7/ctop-0.7.7-darwin-amd64 sudo chmod +x /usr/local/bin/ctop
* Docker:ctopis available in scoop:
Usage¶
ctop requires no arguments and uses Docker host variables by default.
-
Configuration File:
ctopsaves its configuration to~/.config/ctop/config(on XDG systems) or~/.ctop.- Saves filters, sort field, and other options.
- Loads these values the next time
ctopis started.
-
Options:
-a: Show active containers only.-f <string>: Set an initial filter string.-h: Display help dialog.-i: Invert default colors.-r: Reverse container sort order.-s: Select initial container sort field.-v: Output version information and exit.
-
Keybindings:
<ENTER>: Open container menu.a: Toggle display of all (running and non-running) containers.f: Filter displayed containers (esc to clear when open).H: Toggle ctop header.h: Open help dialog.s: Select container sort field.r: Reverse container sort order.o: Open single view.l: View container logs (t to toggle timestamp when open).e: Exec Shell.c: Configure columns.S: Save current configuration to file.q: Quit ctop.
Key Features and Functionality¶
- Real-time Metrics: Provides a dynamic view of CPU, memory, and network usage for each container.
- Container Management: Allows users to start, stop, restart, and remove containers directly from the
ctopinterface. - Filtering and Sorting: Offers options to filter containers based on name or status and sort them by various metrics.
- Single Container View: Enables detailed inspection of a specific container, including logs and resource utilization.
- Customization: Supports configuration of display options, such as color schemes and column selection.
- Docker and runC Support: Works seamlessly with Docker and runC container runtimes.
Building from Source¶
Build steps can be found in the repository's documentation.
Conclusion¶
ctop is a valuable tool for developers and system administrators who need a quick and efficient way to monitor and manage Docker containers. Its top-like interface, combined with container management capabilities, makes it a useful utility for understanding container resource usage and troubleshooting performance issues. The ability to customize the display and integrate with different container runtimes enhances its flexibility and makes it a versatile addition to any container management workflow.