How to Build a Rancher & Docker Based Cloud

How to Build a Rancher & Docker Based Cloud


To build your own fail-safe cloud in your data center, you will need some basic Docker knowledge. And then you can keep calm as K&C’s Docker consultants and DevOps engineers are here to help. Let’s start.


We will use a considerable program stack:


Named (round-robin) — Balancing by DNS
NGINX — Web server for proxying requests for a web application
Docker — Software for automation of the application deployment and management within the virtualization environment at the operating system level
Docker compose — A tool for starting and connecting to several Docker containers
Docker registry — Software for storing Docker images
Rancher — Rancher Labs develops software which allows easy deployment and management of containers within any organization operating on any infrastructure
Rancher compose — Operates on the principle of Docker compose, serves for activation of the Rancher functions
Consul — A utility for Service Discovery and Key/Value Storage
Jenkins — A continuous integration tool written in Java

To build a basic infrastructure (without NA), we will need the following:


IP                               DNS


* The IPs shown were taken from a real system and are required to match screen shots.


1. Setting up a local DNS

The cloud is built within our network, for which purpose a separate zone shall be created.


Edit the configuration file named

Now create a zone file:

2. Setting up a master server

And restart Named

DNS has been set up, so proceed to creating a master server

The master server will accommodate: 

– Rancher-server
– Consul-server
– Jenkins 


Start up the container with Rancher

Our Rancher server is available at


Let’s set up authorization: 


1. Admin -> Access Control
2. Select LOCAL 

3. Add a new user



Set up environments:


1. Go to the tab: Default
2. Click: Add Environment
3. Select: Cattle
4. Type the name and add users 

Setting up your own registry


1. Go to the tab Infrastructure -> Registries

2. Select: Custom
3. Insert your values 

Create an API key


1. Go to the tab: API
2. Generate and write down your values 

Let’s finish with Rancher for the time being and come back to it when setting up clients


Start up the container with consul-server

Consul is (will be) available at

Start Jenkins

Jenkins is (will be) available at

3. Setting up clients

Start up two Docker containers on CloudClient1 and CloudClient2

– Rancher client
– Consul registrator 



To start Rancher client, go to Rancher master:


1. Go to Infrastructure -> Hosts

2. And click: Add Host
3. Enter the external IP of the server in item 4
4. Copy the content of item (from) 5

Start up containers with Rancher and Consul on CloudClient1

Do the same on CloudClient2 but change the IP addresses

If everything has been successfully completed, then we will see our servers in Rancher

* Please, ignore the launched services

4. Setting up a project

To create a project in Rancher, you need to create a docker-compose v1 file, add data obtained from the API, and download Rancher-compose.


Rancher does not collect projects from Dockerfile, but downloads them from the registry. For this reason, collect either locally or from any host


Create a homepage project:

Also, create a simple build script

Export global variables

And download Rancher-compose (Link in the bottom right-hand corner in Rancher)

Add the project to Rancher

Start the project

If everything has been successfully completed, then we will see the following in Rancher:

We will also see the following in Consul:

5. Setting up a WEB server

Install NGINX and download consul-template

Create a Consul-template for NGINX

Start NGINX and consul-template

Now, Consul-template will keep track of changes in Consul-server and rewrite data to the NGINX configurations.

6. Jenkins CI

The final tweak in our cloud is adding continuous integration.

For this purpose, add values obtained from the API to the configuration in Jenkins

Create a Job and insert the following in the shell exec item


Once everything has been completed, we will have a cloud project which can be deployed by clicking on a button. The containers are up on the least loaded hosts and linked between each other via the internal Rancher network.


I have not described all the capabilities of this cloud because it takes time, but I have described the basic capabilities.


Now you can continue on your own!

Add comment

E-mail is already registered on the site. Please use the Login form or enter another.

You entered an incorrect username or password

Sorry that something went wrong, repeat again!
Contact us