Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to Docker Swarm

Temporary environment variables

# IP Address of master machine

# IP Address of node machine

On the master


docker run -d --restart always -p 4001:4001 -p 7001:7001 --name swarm-etcd microbox/etcd --name swarm-etcd

Run the manager

docker run -d --name swarm-manager --restart always -p 3375:2375 swarm manage etcd://$masterip:4001

On each node

Run the daemon

docker run -d --name swarm-proxy --restart always -p 2375:2375 -v /var/run/docker.sock:/var/run/docker.sock ehazlett/docker-proxy:latest

Join the cluster

docker run --restart always -d --name swarm-join swarm join --advertise $nodeip:2375 etcd://$masterip:4001

Start a container on the cluster

docker -H tcp://$masterip:3375 run --rm docker ping -c 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment