Basic Docker swarm Operations

Docker swarm mode natively built on top of docker engine, So it’s easier to orchestrate and clustering capabilities on containers using docker swarm mode.

Following commands summarize basics of swarm mode operations.

Initialize a swarm
docker swarm init --advertise-addr <manager-ip-addr>

Swarm Status
docker info

List all swarm nodes
docker node ls

Get Swarm token to join as worker
docker swarm join-token worker

Get Swarm token to join as manager
docker swarm join-token manager

View all swarm services
docker service ls

Create a swarm service
docker service create --replicas 1 --name <name> <image> <command>

Inspect a running swarm service
docker service inspect --pretty <service-name>

Scale up/down a swarm service (increase/decrease replicas)
docker service scale <service-name>=<no-of-replicas>

Remove a swarm service
docker service rm <service-name>

Setup rolling update interval when creating service
docker service create --replicas 3 --name --update-delay 10s

Rolling Update running swarm service
docker service update --image <service-name>

Force Update stuck service updates without rolling manner
docker service update <service-name>

Filter swarm services by running state
docker service ps --filter="running" <service-name>

 

Hope this helps to get started with docker swarm. For more information:: https://docs.docker.com/engine/swarm/#feature-highlights

One thought on “Basic Docker swarm Operations”

Leave a Reply

Your email address will not be published. Required fields are marked *