Ctop – Top command for container metrics


(: March 3, 2019)

Have you been searching for a top like interface for container metrics and monitoring?. Ctop is a command line tool written to provide a concise and condensed overview of real-time metrics for containers running in your system. This command line tool comes with built-in support for both Docker and runC container engines.

Installing ctop on Linux / macOS

Ctop is written in Go and distributed as binary file which you can quickly download from Github and install it. Fetch the latest release for your platform and download with your wget or curl command.

Install ctop on Linux

export VER="0.7.2"
wget https://github.com/bcicen/ctop/releases/download/v${VER}/ctop-${VER}-linux-amd64 -O ctop
chmod +x ctop
sudo mv ctop /usr/local/bin/ctop

Install ctop on macOS

If you’re running OS X, you can install ctop with brew or by downloading the latest pre-built binary file from Github.

.td_uid_2_5d90859c26512_rand.td-a-rec-img{text-align:left}.td_uid_2_5d90859c26512_rand.td-a-rec-img img{margin:0 auto 0 0}

Install ctop with brew:

brew install ctop

For manual package download, it is similar to below.

export VER="0.7.2"
sudo curl -Lo ctop https://github.com/bcicen/ctop/releases/download/v${VER}/ctop-${VER}-darwin-amd64
chmod +x ctop
sudo mv ctop /usr/local/bin/ctop

Confirm that is working.

$ ctop  --help
Usage of ctop:
-a show active containers only
-connector string
container connector to use (default "docker")
-f string
filter containers
-h display this help dialog
-i invert default colors
-r reverse container sort order
-s string
select container sort field
show cpu as % of system total
-v output version information and exit

Running ctop in Docker container

If you have big love for containers, you can run ctop in a docker container. But first install Docker in your system using the guide below,

How to install Docker CE on Linux

Once docker is installed and running, spin up ctop container by running:

docker run --rm -ti 
-v /var/run/docker.sock:/var/run/docker.sock

Running ctop

Using ctop is easy, just run the command ctop and you should get containers metrics displayed to you in realtime.

$ ctop

Sample output

Ctop Keybindings

Key Action
<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)
S Save current configuration to file
q Quit ctop

Other interesting container articles.

How to Optimize Linux System with Stacer

How to Deploy and Use Dokku on Ubuntu 18.04

How to Install Minikube on Ubuntu 18.04

Install Docker and Docker Compose on Linux Mint 19

How to run Docker Containers on Windows Server 2019

How to setup 3 node Kubernetes Cluster on Ubuntu 18.04 with Weave Net CNI

.td_uid_4_5d90859c2670a_rand.td-a-rec-img{text-align:left}.td_uid_4_5d90859c2670a_rand.td-a-rec-img img{margin:0 auto 0 0}

Comments are closed, but trackbacks and pingbacks are open.