Learn to monitor and manage your Docker Swarm cluster using Docker Visualizer for a simplified visual interface.
In this lesson, you will learn how to monitor your Docker Swarm cluster and manage its services through a visual interface. While the command-line tools docker service ls and docker service ps are effective for checking which services are running on which nodes, they can become cumbersome as your cluster scales.
For clusters with multiple nodes and services, consider using Docker Visualizer to simplify monitoring and management.
Docker Visualizer is a user-friendly tool available on Docker Hub under Docker Samples. Look for the image named “visualizer” when browsing Docker Samples. The help section on its Docker Hub page provides all necessary instructions for running the tool.
Deploying Docker Visualizer on Your Docker Swarm Cluster
To deploy Docker Visualizer, execute the following commands on your Docker master node. This first command creates a Docker service for the visualizer:
Alternatively, you can run the visualizer as a standalone interactive container. This command binds the host’s Docker socket and maps port 8080:
Copy
docker run -it -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock dockersamples/visualizer
Once the container launches, Docker will download the image if it is not already available locally. Open your web browser and navigate to:http://<your-docker-master>:8080This interface displays your Docker Swarm cluster topology, including the master node, worker nodes, and the details of individual services and containers.
Below is an example of deploying a Docker stack for an application. The output shows the creation of various services and provides a snapshot of the current state of your Docker services:
Copy
root@docker-master:/root/voting-app-stack# docker stack deploy voting-app-stack --compose-file docker-stack.ymlCreating service voting-app-stack_dbCreating service voting-app-stack_workerCreating service voting-app-stack_resultCreating service voting-app-stack_voteCreating service voting-app-stack_redisroot@docker-master:/root/voting-app-stack# docker service lsID NAME MODE REPLICAS IMAGE PORTS2nq2ztvpy61 voting-app-stack_vote replicated 2/2 dockersamples/examplevotingapp_vote:latest *:5000->80/tcpaeoxuz73m4tr voting-app-stack_result replicated 0/1 dockersamples/examplevotingapp_result:latest *:5001->80/tcpi6xh43nVj60 voting-app-stack_redis replicated 1/1 redis:latestkhiivku6vbt2 voting-app-stack_db replicated 1/1 postgres:9.4roz4lu9f823x voting-app-stack_worker replicated 0/1 dockersamples/examplevotingapp_worker:latestroot@docker-master:/root/voting-app-stack# docker run -it -d -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock dockersamples/visualizerUnable to find image 'dockersamples/visualizer:latest' locallylatest: Pulling from dockersamples/visualizer8c8727412375: Downloading [================> ] 17.5MB/19.19MB8a4e2c2f84d4: Download complete8a4e2e96a4e3: Download complete3597b94b8cfe: Download complete729775f62015: Download complete9b40b6c4b671: Download complete6d05668a7853: Download complete6d0879a890a6: Downloading [================> ] 23.9MB/29.09MB
The Docker Visualizer interface presents a clear and dynamic view of your Docker Swarm topology, showcasing nodes, running containers, and resource usage details. This visual approach enhances your ability to manage and troubleshoot cluster deployments.
Thank you very much for your time, and happy learning!