Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to Docker Swarm

Temporary environment variables

# IP Address of master machine
masterip=192.168.0.101

# IP Address of node machine
nodeip=192.168.0.14

On the master

Run ETCD

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 4.2.2.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment