Original Docker swarm cheat-sheet
Docker swarm is cluster environment for docker containers. Swarm is created with number of machines running docker daemons. Collectively they are managed by one master node to run clustered environment for containers!
In this article we are listing out all the currently available docker swarm commands in a very short overview. This is cheat sheet you can glance through to brush or your swarm knowledge or quick reference for any swarm management command. We are covering most used or useful switches with the below commands. There are more switches available for each command and you can get them with –help
Read all docker or containerization related articles here from KernelTalk’s archives.
This set of command is used mainly to start, manage swarm cluster as a whole. For node management within cluster we have different set of commands following this section.
docker swarm init
: Initiate swam cluster
docker swarm join-token
: Lists join security token to join another node in swarm as worker or manager
docker swarm join
: Join already running swarm as a worker or manager
docker swarm leave
: Leave swarm. To be run from node itself
docker swarm unlock
: Unlocks swarm by providing key after manager restarts
docker swarm unlock-key
: Display swarm unlock key
docker swarm update
: Updates swarm configurations
Node is a server participating in Docker swarm. Node can either be worker or manager in swarm. Manager node has ability to manage swarm nodes and services along with serving workloads. Worker nodes can only serve workloads.
docker node ls
: Lists nodes in swarm
docker node ps
: Display tasks running on nodes
Above all switches applies here too.
docker node promote
: Promote node to manager role
docker node demote
: Demote node from manager to worker role
docker node rm
: Remove node from swarm. Run from manager node.
docker node inspect
: Detailed information about node
docker node update
: Update node configs
With stacks it is possible to manage application composed by a group of services.
docker stack deploy
: Deploy new stack in the cluster (also accept up
)
docker stack ls
: List stacks
docker stack ps
: Lists services task of stacks
docker stack rm
: Remove stack (also accept remove
and down
)
docker stack services
: List the services in the stack
Docker service is used to create and spawn workloads to swarm nodes.
docker service create
: Start new service in Docker swarm
Switches of docker container run command like -i (interactive), -t (pseud terminal), -d (detached), -p (publish port) etc supported here.
docker service ls
: List services
docker service ps
: Lists tasks of services
docker service logs
: Display logs of service or tasks
docker service rm
: Remove service
docker service update
: Update service config
Most of the parameters defined in service create command can be updated here.
docker service rollback
: Revert back changes done in service config.
docker service scale
: Scale one or more replicated services.
servicename=number format
docker service inspect
: Detailed in formation about service.