Docker Swarm Visualizer
From my previous article, Docker Swarm
things were starting to get a interesting when scaling applications
using Docker Swarm using the
docker service scale command. It’s so
easy to scale up an application with a single command.
One thing that did start getting hairy: where were those apps running?
docker service ls reported the running apps, but not on which node.
docker ps on the individual node showed in detail what the node was
running in terms of containers.
One thing I forgot to mention, the command
docker service ps <service
name> gives a more detailed report on the nodes, so there’s no need
to login to each node and run
docker service ps is so
This is fine for a small number of nodes, what happens when there’s greater number of apps? It grows linearly, while text is convenient, a picture is worth a thousand words!
Enter: Docker Swarm Visualizer
This is a tool I discovered from another blog. I found this to be really nifty so I want to incorporate it into the current set up I have.
If you would like to follow along, please:
- Install Virtualbox
- Download this Vagrantfile to your local folder and modify this line:
vagrant upto create virtual computers: manager and worker1.
Install visualizer Image
The Docker Image for the visualizer is available at hub.docker.com/dockersamples/visualizer. This only needs to be on the manager node.
Install the visualizer on manager by running the following command on the manager node:
Start: Docker Visualizer
To get Docker Visualizer going, the following section of configuration from the Vagrantfile is important to understand:
means that any server running inside manager using port 3000 will be accessible to the host computer on port 3500 (i.e. http://localhost:3500)
What I will do is configure the Docker Swarm visualizer web server to run on manager’s port 3000:
And this will allow us to see the visualizer on a browser by going to address: http://localhost:3500.
If everything is working, this is the expected image:
If you see something else contact me.
Add a service
A swarm without a service is pretty boring, so let’s add a service.
Use the following command to create a new nginx service:
Now, the browser should display an image like:
OR, the image can be like this:
It may depend on how Docker Swarm would distribute the service.
Cool, a service pops up showing where its running. No need to run any commands to log into a node to see what is running and where.
One service is interesting, but let’s scale the service to four and see what happens:
Now, if we look at the browser, the Docker Swarm Visualizer would most likely show:
Docker Swarm Visualizer is a great way to see what is going on with services on a Docker Swarm in a visual manner. There’s no need to log in to individual nodes and/or run commands.
Just run Docker Swarm Visualizer, create services, and view in a browser.
Getting Docker Swarm Visualizer incorporated into the virtual network required port mapping from Docker Swarm Visualizer’s 8080, to the guest’s 3000, to the host’s 3500. Nothing crazy, right?
Remember, Docker Swarm Visualizer is a learning tool and NEVER use in production systems.