My Docker Support Stack
Here at SSENSE we work with many microservices and it can quickly become difficult to follow what’s going on. Some are deeply dependent on others while some require developers to run a local version of AWS services with limited functionalities. To ease my local workflow and understand what’s going on when I click a button or run a container, I rely on the help of three tools: Portainer, WeaveScope, and a customized version of Log-Io for Docker.
Portainer
Portainer is designed to manage containers. It can run on the cloud and connect to different servers running Docker, but in our case we use it locally. This tool is a great way to run actions on one or multiple containers. It gives you detailed information on your containers, images, and volumes the same way you would get from the Docker command line, but with an organized and intuitive user-interface.
WeaveScope
This tool was originally built for Kubernetes and later included support for Docker. It allows you to see all your running containers from a bird’s eye view. What’s interesting is once it detects a network connection between container, it links them together in the view. This tool is not as robust as Portainer but serves a different purpose. It displays a graph to visualize communication between containers.
Log-Io for Docker
While looking for a solution to help me follow logs from several microservices, I stumbled upon this on GitHub: a web interface that pulls logs from docker containers.
I’ve updated the docker-compose file to a more recent one here. In the following sections, I will present a walkthrough of the previously listed tools and their installation.
Portainer Walkthrough
Installation
With this one step, you can have Portainer on your machine running on port 9000, binding the docker.sock
to itself, and saving its data to the volume named portainer_data
:
docker run -d -p 9000:9000 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
— name portainer \
portainer/portainer
Tutorial
Upon installation and after selecting the local Docker socket to connect to, you will be greeted with the homepage that shows your local connection and some aggregated information. In this case, I have 3 stacks running (a network, and its containers created by docker-compose), including 36 containers linked to 34 volumes. I also have 163 images on my laptop.
Clicking on the local connection tab opens a dashboard of your local Docker deployments as shown below. It also provides additional information about disk usage by images, in this case a whopping 114 GB! My case definitely seems apt for a prune
!
The view above offers more in-depth data about the categories listed in the sidebar: stacks, containers, images, volumes and networks.
Clicking on the ‘Stacks’ page shows the groups of containers you have created using docker-compose
. If they were created by docker run
, they will only show up in the containers page.
The containers page is a very useful one. It gives you a way to search and filter containers by name. Each container with open ports provides clickable links to its ports. The dashboard also allows you to perform actions on many containers at once: stop, kill, etc. The quick action buttons give you direct access to containers via the following buttons: ‘logs’, ‘inspect’, ‘monitor’, and ‘shell’. I find ‘logs’ to be the most useful since it gives you an interface to trace logs and perform filtering. The second would be the ‘shell’ button which allows you to use bash
, sh
, ash
or a custom CLI option to get into containers. Then comes the monitor page which provides CPU, network, and memory information about the selected container.
Clicking on the container name presents the container’s metadata, with the possibility of performing other actions such as creating an image from it, exploring its environment variables, inspecting its base images, changing its restart policies, modifying attached volumes, etc.
Next comes the ‘Image’ page that provides information about each image (tag, image size, if it’s used, etc.). Once you click on an image you see its details and have the option to delete or export it. A very useful subsection is ‘Image layers’ which shows all the steps in the Dockerfile executed to create the image. I want to stop you here for a moment and suggest that you go see the detailed view of your running Portainer container, and set its restart policy to always
so that it restarts automatically on boot.
Clicking on the “Volume” page greets you with a list of volumes and their mount point, which are their paths on your local machine. If you created any named volumes, they will show up as well. Clicking on one shows you which container it is mounted to.
WeaveScope Walkthrough
Installation
The instructions are provided here.
Tutorial
At first, the WeaveScope interface can be a little confusing. At the top are “what” you want to look at: processes, containers, and hosts. ‘Processes’ shows what processes are running on your machine and ‘Hosts’ just shows your local machine. Arguably the most valuable tab is ‘Containers’, which shows each container as a hexagon, which link together when a connection between them has been identified. Clicking on one shows notable information about the container. Clicking on ‘CPU’ at the top will display the CPU usage of that container as a bar in the hexagon, and display the value on mouseover.
At the top there’s also the ‘Graph’, ‘Table’, and ‘Resources’ tabs. These offer a different view of the same data. ‘Table’ allows you to sort your containers by any of the headers. It’s useful to quickly see which container is using a lot of CPU or RAM.
Log-Io for Docker Walkthrough
Installation
I’ve created an updated version of the docker-compose file to use here. To start it, run the command: docker-compose up logs
.
Tutorial
The interface lists the running containers on the left. Selecting one of them filters the logs to show logs of the selected container. There’s a ‘new screen’ button which splits the logs UI and show different logs in different sections of the interface. By hovering your mouse over the logs, a box will appear at the top right allowing you to filter the lines by a value.
Conclusion
In this article, we have covered three tools that we use at SSENSE to help us manage, monitor, and analyze the execution of our containers. These tools are a powerful asset to modern developers who run everything on containers. They offer junior developers a way to grasp their containerized environment, and experienced veterans a means to quickly resolve problems spanning across many microservices.
Editorial reviews by Deanna Chow, Liela Touré & Prateek Sanyal.
Want to work with us? Click here to see all open positions at SSENSE!