📜 ⬆️ ⬇️

docker-pretty-ps - finally convenient for reading “docker ps”

You are not alone in this world, if for a long time you are not happy with what the standard output of docker ps looks like. Although there are various workarounds on this topic (see the end of the material) , one day some enthusiast had to do “something else” ... and this happened in the ensuing 2019. His name is docker-pretty-ps .

The author's idea is utterly banal: horizontal output and colors for clarity.



And as an audience, utilities are called “developers rather than hardcore DevOps or SRE engineers.”

Opportunities


With the appearance of everything should be clear from the picture. What does the utility allow in terms of functions? By default, all running containers are output, but of course the possibilities are not limited to this - in docker-pretty-ps it is supported:


Installation


The project code is written in Python and the authors separately note that third-party Python packages are not used, so it’s enough to run Docker and Python in order to start, which is true for many.

Installation is done via pip:

 pip install docker-pretty-ps 

... or just a simple build:

 git clone https://github.com/politeauthority/docker-pretty-ps.git cd docker-pretty-ps python3 setup.py build python3 setup.py install 

All - you can use:

 $ docker-pretty-ps -h usage: docker-pretty-ps [-h] [-a] [-s] [-i INCLUDE] [-o [ORDER]] [-r] [-j] [-v] [search] positional arguments: search Phrase to search containers, comma separate multiples. optional arguments: … 

Other workarounds


Despite the widespread support on Reddit, this utility is definitely not for everyone. In particular, if you have many containers (dozens or more), then even using the slim mode will not always be convenient. And then one of the well-known workarounds can be more useful.

docker ps --format


The formatting option for docker ps is not just a workaround, but in a sense, the best solution, since does not require anything extra in terms of installation in the system.

The --format argument is accepted by many Docker commands, allowing (via the go-template ) to customize their output for themselves. For the docker ps its support has appeared a long time ago (in the release of Docker 1.8 from August 2015). Here is an example of its use:

 [flant] d.shurupov@kube-node-test ~ $ sudo docker ps --format 'table {{.Names}}\t{{.Image}}' NAMES IMAGE k8s_fluentd_fluentd-jmzjd_loghouse… flant/loghouse-fluentd… k8s_cert-manager_cert-manager-… quay.io/jetstack/cert-manager-controller… k8s_prometheus-config-reloader_… 597141b113d9 k8s_prometheus_prometheus-main-… cc866859f8df k8s_POD_prometheus-main-0_kube-… k8s.gcr.io/pause-amd64:3.1 … 

(NB: In the example above, the full names of the containers and images were manually cropped for better clarity.)

Details on working with --format can be found, for example, in this article , and examples of available functions can be found in the Docker documentation .

ctop


Perhaps even more popular is to use the ctop utility, which offers an interface similar to the classic top , but for Docker containers:



Its convenient launch in the console can be reduced to this alias:

alias ctop='docker run --rm -ti -v /var/run/docker.sock:/var/run/docker.sock quay.io/vektorlab/ctop:latest'

In addition, of course, there are other - more advanced in their capabilities - interfaces, but their description is beyond the scope of the article. What do you use?

PS


Read also in our blog:

Source: https://habr.com/ru/post/436896/