This document provides a cheatsheet for managing Docker Swarm clusters. It outlines commands for initializing and joining nodes to a swarm, deploying stacks, managing networks and services, monitoring services, and integrating with Sematext for cluster-wide logging and monitoring.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
158 views1 page
Docker Swarm Cheat Sheet
This document provides a cheatsheet for managing Docker Swarm clusters. It outlines commands for initializing and joining nodes to a swarm, deploying stacks, managing networks and services, monitoring services, and integrating with Sematext for cluster-wide logging and monitoring.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1
Docker Swarm Cheatsheet Full-stack visibility. Actionable insights. Single pane of glass.
Tutorial Series
Node management Stack management
Initialize a swarm: docker swarm init Deploy stack from docker-compose file: docker stack deploy -c docker-compose.yml stack_name List swarm nodes: docker node ls List stacks: docker stack ls Get the command for new nodes to join a swarm: docker swarm join-token worker or List stack services: docker stack services stack_name docker swarm join-token worker . The command prints the required command and token: E.g. List stack tasks: docker stack ps stack_name Remove stack : docker stack rm stack_name
To add a worker to this swarm, run the following command:
docker node inspect manager-node-name --format "{{ .ManagerStatus.Reachability }}" Monitor services Check node state: docker node inspect node-name --format "{{ .Status.State }}" Put a node in maintenance mode: docker node update --availability drain node_name Docker stats: docker stats Activate a node (after maintenance): docker node update --availability active node_name Service logs: docker service logs service_name Add a label: docker node update --label-add key=value node_name Cluster-wide monitoring and log collection with Sematext Docker Agent on Swarm: Create a Docker App in Remove a label: docker node update --label-rm key node_name Sematext Cloud to get log and monitoring tokens, then run: Search label: docker node inspect node_name | grep Labels -C5
docker service create --mode global --name sematext-agent-docker \
Service management --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \ -e SPM_TOKEN=YOUR_SPM_TOKEN -e LOGSENE_TOKEN=YOUR_LOGSENE_TOKEN sematext/sematext- agent-docker List services (manager node): docker service ls Describe services (manager node): docker service ps service_name Inspect a service: docker service inspect service_name Scale a service: docker service scale service_name=N Remove service: docker service rm service_name
METRICS, EVENTS and LOGS
Sematext is Docker monitoring and logging certified partner START YOUR FREE TRIAL