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 a standard output looks like docker ps. 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.”


    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:

    • withdrawal of all containers (including stopped ones);
    • Container search pattern: docker-pretty-ps my,trydisplays containers, which are found in the title *my*and *try*(e.g., docker-registryand mysql-redmine);
    • several sorting options;
    • customizable display fields for each container (available: container_id, created, ports, image_id, status, command);
    • compact output mode slim(removes all the fields listed above, leaving only the names of the containers):

    • output data in JSON format.


    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
    cd docker-pretty-ps
    python3 build
    python3 install

    All - you can use:

    $ docker-pretty-ps -h
    usage: docker-pretty-ps [-h] [-a] [-s] [-i INCLUDE] [-o [ORDER]] [-r] [-j]
    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 mode slimwill not always be convenient. And then one of the well-known workarounds can be more useful.

    docker ps --format

    The formatting option for docker psis not just workaround, but in a certain sense the best solution, since does not require anything extra in terms of installation in the system. Many Docker commands accept the

    argument --format, allowing (via the go-template ) to customize their output for themselves. For the team, docker psits support has appeared a long time ago (in the Docker 1.8 release 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_prometheus-config-reloader_…         597141b113d9
    k8s_prometheus_prometheus-main-…         cc866859f8df

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

    For details on working with --format, see, for example, this article , and examples of available functions are in the Docker documentation .


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

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

    alias ctop='docker run --rm -ti -v /var/run/docker.sock:/var/run/docker.sock'

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


    Read also in our blog:

    Also popular now: