Monitoring Clusters Using a Visualizer

Adding a GUI service to our swarm cluster

As a developer, these services will definitely excite you. Although we are only covering the fundamentals of Docker swarm and not in-depth networking and deployment, it will feel like an advanced thing to you.

That’s alright. Now, we are going to see our swarm cluster. The image we are going to use for our cluster visualization is dockersamples/docker-swarm-visualizer.

Running on Linux

We can deploy this image as an independent container or as a swarm service. To run as a container, follow the steps below.

Running as a container

Type $ docker run -it -d -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock dockersamples/visualizer

This will run the container with host port 8080 mapped to the container port 8080.

Running as a service

To run a visualizer as a service on swarm node, type, docker service create --name=viz --publish=8080:8080/tcp --constraint=node.role==manager --mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock dockersamples/visualizer

Parameters:

  • --publish: mapping of host and container ports

  • --constraint: location or name of the node on which the service will be created

  • --mount: bind Docker socket to container socket to receive all the events from Docker host

This will create the service on the swarm manager node as mentioned in the constraint parameter.

Open up a browser and go to localhost:8080. You should see something like this:

Get hands-on with 1200+ tech skills courses.