Docker swarm is a clustering system for docker. Today I configured a cluster of 2 machines and started 2 containers. Here is how I built a small swarm of 2 nodes.


  1. Install latest docker
  2. Install latest swarm
  3. Create a swarm
  4. Create nodes
  5. Start docker manager
  6. Ship containers to the swarm

My system:

  • Debian Jessie
  • Docker 1.5.0
  • Docker swarm 0.2.0

I use 3 computers: PC1, PC2, PC3 PC1 runs the swarm manager and PC2 and PC3 are nodes.


  • PC1:
  • PC2:
  • PC3:

1- Install latest docker

Download the docker binary from the web:

wget -O docker
chmod +x docker

Run these commands all computers, PC1, PC2 and PC3

2- Install latest swarm

First, install the go compiler, clone the swarm repository from github and compile.

apt-get install -y golang git;mkdir ~/gocode; export GOPATH=~/gocode;go get

mkdir -p $GOPATH/src/
cd $GOPATH/src/
git clone
cd swarm
$GOPATH/bin/godep go install .

Run these commands all computers, PC1, PC2 and PC3

3- Create a swarm

The swarm command generate the swarm ID.

$GOPATH/bin/swarm create

Run on PC1

4- Create nodes

Start the docker daemon and join the swarm using the swarm id.

./docker -d -H tcp:// -H unix:///var/run/docker.sock
$GOPATH/bin/swarm join --addr= token://a0c405a37b044f6503bb382c196b0346

Run on PC2, PC3

5- Start docker manager

To start docker manager, you need:

  • ip address of PC1:
  • choose a swarm port: 3456
  • swarm id: a0c405a37b044f6503bb382c196b0346
./docker -d
$GOPATH/bin/swarm manage -H tcp:// token://a0c405a37b044f6503bb382c196b0346

Run on PC1

6- Ship containers to the swarm

Run wordpress with mysql in the swarm, I chose port 50000 for wordpress:

./docker -H tcp:// run -d --name my -e MYSQL_ROOT_PASSWORD=my-secret-pw mysql
./docker -H tcp:// run --name some-app --link my:mysql -p 50000:80 -d wordpress

Run on PC1