Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trick to loop/autorefresh docker ps view like top/htop in bash

Tags:

bash

docker

htop

Is it possible - and if yes, how - to have a self-refreshing view of current Docker containers printed by "docker ps" alike top/htop utilities?

like image 855
Open Food Broker Avatar asked Apr 01 '17 17:04

Open Food Broker


People also ask

What command should be run to view all the running docker containers?

In order to list the Docker containers, we can use the “docker ps” or “docker container ls” command. This command provides a variety of ways to list and filter all containers on a particular Docker engine.

What is the command in docker ps?

The docker ps command, which is available inside the container, is used to see the status of the process. This is similar to the standard ps command in the Linux environment and is not a docker ps command that we run on the Docker host machine.

What is the difference between docker ps and Dockerps A commands?

There is no difference between the docker ps (docker process status) and docker container ls (docker container list) commands in terms of functionality. They even allow the same set of flags. The only real difference between the two is the fact that the latter is newer and more verbose than the former.

What does docker compose ps command do?

Creates containers for a service. Receive real time events from containers. Execute a command in a running container. Force stop service containers.


2 Answers

Use watch:

watch docker ps 

See man watch

like image 180
hek2mgl Avatar answered Oct 09 '22 11:10

hek2mgl


Few options:

  1. You can try command docker stats, which will give you some details about current running containers id, cpu%, memory etc. Something similar to top/htop which you asked for.

  2. Command docker top CONTAINER [ps OPTIONS] : It displays the running processes of a container.

  3. There are also some applications available which gives nice view of your docker ecosystem. Eg- Kitematic, Kevana

like image 34
Avichal Badaya Avatar answered Oct 09 '22 11:10

Avichal Badaya