Would you like to build your own personal cloud using native Docker tools? Here is how you can do that.

Cluster Configuration

We will start with three nodes. One of these will run Etcd and Swarm Manager. Other two will be Swarm nodes.

  • (Etcd + Swarm Manager)
  • (Swarm Node)
  • (Swarm Node)

Setting up Etcd

We need a key value store which we will use for discovering various components like network and co-ordinate between Docker Swarm components. Etcd fits nicely in this role.

$ sudo yum install etcd

Configure Etcd to bind and advertise the IP of the machine by editing /etc/etcd/etcd.conf. Find out the lines below and edit them.


After this, we just need to restart the Etcd service.

$ sudo systemctl restart etcd

Start Docker with Cluster Options

Assuming that the Docker is already installed, we need to start it with cluster options like below on all the machines:

sudo docker daemon -H tcp:// -H unix:///var/run/docker.sock --cluster-store=etcd:// --cluster-advertise=eth0:2376

Create Overlay Network

Overlay Network spread across different machines and enables network communication between different hosts.

$ sudo docker network create --driver overlay overlay-net1

Start Swarm Manager

Swarm Manager will manager the Swarm Nodes. We will run the containers on the Swarm Manager and they will be run on one of the Swarm Nodes.

$ sudo docker run -d -p 4000:4000 swarm manage -H :4000 --replication --advertise  etcd://

Start Swarm Nodes

Swarm Nodes do the actual heavy lifting of running the container. We will start the Swarm Nodes while pointing them to the Etcd endpoint. On, run the following

$ sudo docker run -d swarm join --advertise= etcd://

On, run the following

$ sudo docker run -d swarm join --advertise= etcd://

Our tiny cloud is up and running.

Running Container on the Cloud

Now we just fire the regular Docker commands against the Swarm manager port.

sudo docker -H :4000 ps

Whenever we need to run a container which needs to talk to other containers, we put it in the overlay network.

sudo docker -H :4000 run -d --net=overlay-net1 -e MYSQL_ROOT_PASSWORD=my-secret-pw mysql

There we have our multi-node cloud with Docker ready to go!

Next Post Previous Post