Monitoring Docker containers

In this recipe, we will learn to monitor Docker containers.

How to do it…

Docker provides inbuilt monitoring with the docker stats command, which can be used to get a live stream of the resource utilization of Docker containers.

  1. To monitor multiple containers at once using their respective IDs or names, use this command:
    $ docker stats mysql f9617f4b716c
    
    How to do it…

    Tip

    If you need to monitor all running containers, use the following command:

    $ docker stats $(dockerps -q)
    
  2. With docker logs, you can fetch logs of your application running inside a container. This can be used similarly to the tail -f command:
    $ docker logs -f ubuntu
    
  3. Docker ...

Get Ubuntu Server Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.