A while ago, I stumbled upon ctop; a small, yet handy command-line tool to interact with Docker containers and gather essential metrics. You know docker stats? ctop is docker stats on steroids. The open-source tool is available for free and can be installed directly on Linux and macOS.

ctop - Essential metrics for Docker containers

With ctop, you get more than just fundamental metrics. Overall, ctop combines the following features in one single tool:

I use ctop because it is efficient and straightforward. All features are accessible within just one keystroke.

Install CTOP

Linux

Manual Installation:

# Download ctop
sudo wget https://github.com/bcicen/ctop/releases/download/v0.7.3/ctop-0.7.3-linux-amd64 -O /usr/local/bin/ctop
# change file mod to make it executable
sudo chmod +x /usr/local/bin/ctop

MacOS

Installation with Homebrew:

brew install ctop

Manual installation:

# Download ctop
sudo curl -Lo /usr/local/bin/ctop https://github.com/bcicen/ctop/releases/download/v0.7.3/ctop-0.7.3-darwin-amd64
# change file mod to make it executable
sudo chmod +x /usr/local/bin/ctop

Run It In A Container

Alternatively, you can run ctop directly inside of a Docker container.

docker run --rm -it --name ctop-container \
  --volume /var/run/docker.sock:/var/run/docker.sock:ro \
  quay.io/vektorlab/ctop:latest

CTOP Keybindings

Navigation in ctop is simple but efficient. Learn the following keybindings to get most out of ctop.

Key Action
h Show help dialog
l Show container logs
e Exec Shell
q Close ctop
[ENTER] Open container menu
a Toggle view (running / all containers)
f Filter view (ESC to close filter view)
H Toggle Header
s Select sort field
r Reverse sort order
o Open single view for selected container

Stream Container Logs With CTOP

From the main view, select the desired container using arrow keys and hit l top access the log stream of the container

Docker Container log stream with ctop

While you are learning the keybindings, you could use the container menu to navigate. Just select a container - arrow keys - and hit [ENTER]. ctop will bring up a contextual menu, showing all available actions in the context of a particular Docker container.

ctop - Access functionalities with container menu

Conclusion

I love the simplicity and efficiency of ctop. I can access a bunch of container-related features within just one keystroke. It makes investigating super-efficient and increases overall productivity. Do you use another tool to achieve this? I would love to learn about your setup and see other opportunities.