How to Install Rancher Docker Container Manager on CentOS 7

Rancher is an open source container management platform. It allows you to run and manage Docker and Kubernetes with ease. Rancher provides infrastructure services such as multi-host networking, load balancing, and volume snapshots.

In this tutorial, I will guide you to step-by-step install and configure Rancher Server and Agent on CentOS 7 server. We will install Docker and Rancher on the CentOS server, enable local authentication Rancher server, add the rancher host, and then try to deploy container application 'Ghost' from Rancher Dashboard.

Prerequisites

  • CentOS 7
    • host01 - 192.168.33.10
    • host02 - 192.168.33.11
  • Root privileges

What we will do?

  1. Install Docker on CentOS 7
  2. Install Rancher Server
  3. Enable Local Authentication Rancher Server
  4. Add New Host
  5. Deploy New Container

Step 1 - Install Docker on CentOS 7

Rancher can be installed as a set of Docker Containers, one container as a management server and another as an agent. And we need Docker installed on all our rancher host and agent.

Install Docker on CentOS 7 using the yum command below.

yum -y install docker

After the installation is complete, start the service and add it to the boot time.

systemctl start docker
systemctl enable docker

Docker installed on the rancher host server - check it using commands below.

systemctl status docker
docker --version

And you will get the result as shown below.

Install Docker on CentOS 7

Step 2 - Install Rancher Server

To run and install Rancher, we just need to run the Rancher container on our server host. In this step, we will install Rancher Server single container on our 'host01' server.

Before installing Rancher server on 'host01' server, we will create and define a new directory as a Rancher database volume.

Run the commands below.

HOST_VOLUME=$HOME/rancher-data/mysql
mkdir -p $HOST_VOLUME

Now install Rancher server using the docker command below.

sudo docker run -d \
-v $HOST_VOLUME:/var/lib/mysql \
--restart=unless-stopped \
-p 8080:8080 \
rancher/server

Wait for the Rancher server installation.

Install Rancher Server

When the installation is complete, Rancher server is accessible from the web browser.

Open your web browser and type the server IP address with port 8080.

http://192.168.33.10:8080/

And you will get the Rancher first page installation as below.

Rancher installation - first page

Rancher server has been installed on CentOS 7 server and is now running on default port 8080.

Step 3 - Enable Local Authentication on Rancher Server

After the Rancher installation, we need to configure the Rancher Access Control. The Access Control allows you to manage users who have the access permissions to your Rancher server.

Rancher supports many access control providers, including Active Directory, Azure AD, Github, OpenLDAP, SAML, and Local Authentication.

For this guide, we will enable the local authentication for our Rancher server installation.

Open your web browser and type the server IP address with port 8080.

http://192.168.33.10:8080/

Move your cursor to the 'ADMIN' menu drop-down and click the 'Access Control'.

Enable Local Authentication on Rancher Server

Now we want to use the 'Local Authentication' method. Click 'LOCAL' on the page, then type your username and password.

Configure authentication

Click 'Enable Local Auth' button and you will be redirected to the Rancher admin dashboard.

Access Control for the Rancher server has been setup with Local Authentication enabled.

Step 4 - Add New Host

Hosts are the most basic unit of resource within Rancher and represented as any Linux server (a virtual or physical server with Docker installed on it).

In this step, we will add new host 'host02' with Ubuntu as an operating system and with the 2GB of RAM.

Connect to the 'host02' server using the ssh.

ssh [email protected]

Now install Docker on it using yum command.

yum -y install docker

And when the installation is complete, start docker and enable it to launch everytime at system start.

systemctl start docker
systemctl enable docker

Docker has been installed on the 'host02' server.

Install Docker

Next, we will add host02 to the Rancher as a host.

Open the Rancher Dashboard, move your cursor to the 'INFRASTRUCTURE' menu and click 'Hosts'.

Open the Rancher Dashboard

Now click the 'Add Host' button.

Add new host

For the Host Registration URL, we will use default as shown below.

Enter host URL

Click 'Save button'.

Now select the Host type, Rancher support for many type of hosts including Amazon EC2, Azure, DigitalOcean, Rackspace Hosts.

Select the 'Custom' host, type the 'hots02' IP address, and copy the docker command on the box.

Custom host type

Now open the host02 terminal shell and paste the following command.

sudo docker run -e CATTLE_AGENT_IP="192.168.33.11"  --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.10 http://192.168.33.10:8080/v1/scripts/BCF2EFCA73A02954EBDF:1514678400000:OdRDdvnEUbV2hUMAFIS3oQxcTt4

The command will download and run new container for Rancher Agent.

download and run new container for Rancher Agent

And when it's complete, you will get the result as shown below.

container download completed

Now back to the Rancher Dashboard Host Add page and click the 'Close' button.

And you will see the 'host02' on the page as shown below.

Host 2 shown in Rancher

host02 has been added to the Rancher server, and we're now ready to run container managed by Rancher server.

Step 5 - Test Create New Container

Rancher provides a catalog for applications. The available application templates make deployment easier.

Rancher provides two types of catalogs. The Library catalog that contains templates from the Rancher certified catalog, and the Community catalog that contains templates from the Rancher Community-catalog.

In this step, we will try to deploy a simple blog platform 'Ghost' as a container through the Rancher Catalog Community Templates.

On the Rancher Dashboard, move the cursor to the 'CATALOG' menu and click the Community Catalog.

Rancher catalog

In the 'Search' box, type the application name that we want to install ('Ghost').

search application

Click the 'View Details' button.

Give the new Ghost container a name and description.

enter name and description for container

Then click the 'Launch' button.

When it's complete, you will get the result as below.

Launch container

The 'Ghost' container has been created and is now running on Rancher agent server.

Now move your cursor to the 'INFRASTRUCTURE' menu and click 'Host'. Now make sure you get the 'ghost' container is running on the 'host2' server.

Host infrastructure

To verify the Ghost container installation, open your web browser and type the 'host02' IP address and you will get the ghost blog default homepage.

http://192.168.33.11/

Ghost blog is working

Rancher server and Rancher agent installation on Ubuntu 16.04 has been completed successfully.

Reference

Share this page:

Suggested articles

0 Comment(s)

Add comment