There are multiple ways to monitor docker, at the end the power user will probably stick with the command line tools, but at least two free software can definitively help. And cherry on the cake, the two of them can be deployed as containers.

The classic way to monitor docker

The classic way to monitor to docker is to use the stats command line.

docker stats

It gives up a result that looks like follows:

CONTAINER           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O               BLOCK I/O             PIDS
09ad3e8ebaa4        0.03%               9.982 MB / 33.69 GB   0.03%               96.7 MB / 98.06 MB    6.71 MB / 8.192 kB    2
7713e778dce1        0.00%               8.708 MB / 33.69 GB   0.03%               7.398 kB / 648 B      7.564 MB / 0 B        4
05d38f4c746b        0.17%               344 MB / 33.69 GB     1.02%               7.945 MB / 135.7 MB   53.28 MB / 8.192 kB   45
c461a22d3bf0        1.96%               576.4 MB / 33.69 GB   1.71%               1.311 GB / 1.949 GB   170.7 MB / 1.367 GB   58
c175edcc1998        0.00%               85.74 MB / 33.69 GB   0.25%               24.79 GB / 132 MB     6.898 MB / 0 B        1

It looks like the docker developers thought that knowing your container name is not that important.

Of course, using a command line like follows is a little bit more readable but not that easy to remember.

docker stats $(docker ps | awk '{if(NR>1) print $NF}')

Now the results are more usable:

CONTAINER           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O               BLOCK I/O             PIDS
nginx               0.00%               10.02 MB / 33.69 GB   0.03%               97.16 MB / 98.54 MB   6.71 MB / 8.192 kB    2
dockerui            0.00%               8.708 MB / 33.69 GB   0.03%               7.398 kB / 648 B      7.564 MB / 0 B        4
camelworker2        0.13%               344 MB / 33.69 GB     1.02%               7.961 MB / 135.8 MB   53.28 MB / 8.192 kB   45
camelworker1        2.17%               578.2 MB / 33.69 GB   1.72%               1.314 GB / 1.953 GB   170.7 MB / 1.37 GB    58

The Web 2.0 way

Portainer (Formely docker ui)

This is a simple container linked via the docker socket that has a simple but efficient interface. If you want to integrate it into your docker compose file, simply add the following lines to your compose file:

##############################
  dockerui:
    image: portainer/portainer
    container_name: dockerui
    ports:
      - 9000:9000
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

Don’t forget to add a reverse proxy like NGINX in front of if you want to secure the access to the software. (That’t the same logic as the one used to secure Kibana available in one of our previous post)

portainer.jpg

Weave Scope

Weave scope is a little bit trickier but it has a very sexy GUI.

##########################################
  weavescope-probe:
    image: weaveworks/scope:1.1.0
    privileged: true
    links:
      - weavescope-app
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
    tty: true

    command:
      - "--probe.docker"
      - "true"
      - "--no-app"
      - "weavescope-app:4040"

    container_name:
      weavescope-probe

#######################################

  weavescope-app:
    image: weaveworks/scope:1.1.0
    privileged: true
    ports:
      - "4040:4040"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"

    command:
    - "--no-probe"

    container_name:
      weavescope-app

 weavescope