Rancher – Your Private Container Service : Run Containers in Production – Install Rancher on CentOS 7 / Ubuntu 16.04

0

Rancher is an open source software that helps you to run the containers in production. With rancher, you no need to build containers from scratch; it supplies entire software stack needed to manage container.

Components:

INFRASTRUCTURE ORCHESTRATION: It is nothing but a computing resource (Linux Hosts), could be a virtual machine or physical machine.

CONTAINER ORCHESTRATION AND SCHEDULING: Container orchestration is a tool by which you can integrate and scale the containers in enterprise production. These tools are mainly aimed to simplify the container management and provide a framework for managing the multiple containers as one entity (it is nothing but a Docker cluster). Rancher includes those tools such as Docker sworm, Kubernetes, and Mesos.

APPLICATION CATALOG: With Rancher, an entire multi-container clustered application from the application catalog with one click of a button. Rancher maintains a public catalog consisting of popular applications contributed by the Rancher community.

ENTERPRISE-GRADE CONTROL: Rancher supports multiple authentication mechanisms such as Active Directory, LDAP, and GitHub.

In this tutorial, we will look into a single host Rancher installation, in which we run everything on a single Linux machine.

Prerequisites:

Linux host must have a kernel version 3.10 and above, should have at least 1GB memory.

Install Docker on CentOS 7 / RHEL 7 / Fedora 24

Install Docker on Ubuntu 16.04

Start Rancher Server:

Switch to root user

$ sudo su -

Execute the following command to launch the Rancher Server.

# docker run -d --restart=always -p 8080:8080 rancher/server

Verify that Rancher Server container is running without any issue.

# docker ps

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                            NAMES
547cec7cc306        rancher/server      "/usr/bin/s6-svscan /"   3 minutes ago       Up 3 minutes        3306/tcp, 0.0.0.0:8080->8080/tcp   compassionate_dubinsky

Please stand by for a while, try accessing the following URL.

http://server_ip:8080

If you are not able to access the Rancher, go through the rancher logs.

# docker logs -f

Replace the containerid with the output of “docker ps”

Working with Rancher:

Add host:

Since we are doing a single host Rancher installation, we will add the same host running the Rancher server as a host into Rancher UI. In the production environment, we recommend using the dedicated compute host for running the Rancher Server.

Go to Infrastructure –> Add Hosts

Rancher - Your Private Container Service - Add Hosts
Rancher – Your Private Container Service – Add Hosts

If you are doing for the first time, Rancher will prompt you to select an IP address and it must be reachable to all hosts that you will be adding.

If your host is running behind NAT firewall or load balancer, Rancher will print a warning; you can ignore these warning as we will be adding Rancher server host itself.

Just click Save.

Rancher - Your Private Container Service -Select an IP
Rancher – Your Private Container Service -Select an IP

Rancher will take you to next page where you will be presented with cloud providers. Since we will be adding the host that is running Rancher server, we will select the “custom” option. Once you selected the custom option, Rancher will provide a command to use to add hosts.

Enter the public IP address of the host in the text box provided in the 4th step, now copy the whole command provided in the 5th step and run it on the Rancher host.

Rancher - Your Private Container Service - Custom
Rancher – Your Private Container Service – Custom

Once the command is executed, click close on the Rancher UI. Wait for a while; the host will be soon visible in Infrastructure –> Hosts page.

Rancher - Your Private Container Service - Hosts
Rancher – Your Private Container Service – Hosts

Getting Started with First Container:

On Host Page, click on Add + Add container; Rancher will take you to Add container page where we will create our first container.

Just name your container like Ubuntu, Type the name of the image you wish to run as a container. For ex: ubuntu:latest and then click on Create

Rancher - Your Private Container Service - Create Our First Container
Rancher – Your Private Container Service – Create Our First Container

You will now see that creation of Ubuntu container is in progress. It will hardly take a minute, but, it depends on internet connectivity if the image needs to be pulled from Docker registry.

Rancher - Your Private Container Service - Container Creation in Progress
Rancher – Your Private Container Service – Container Creation in Progress

Managing Docker Containers:

Once the container is created, the container will start on its own. You can see the state as running with all details such as host, IP address, and command. You can see the performance of the container by clicking on Infrastructure —> Containers –> <container name>.

Rancher - Your Private Container Service - Container Performance
Rancher – Your Private Container Service – Container-Performance

With Rancher, you can also perform admin tasks such as stop, start, clone, restart, and able take the shell of a container.

Rancher - Your Private Container Service - Aministrative Tasks
Rancher – Your Private Container Service – Administrative Tasks

You can also take the console of the container just from the Rancher UI.

Rancher - Your Private Container Service - Shell Access
Rancher – Your Private Container Service – Shell Access

Rancher not only manages containers that are created by own; it can also manage that are created with native Docker commands.

For example, let’s create a CentOS container using the Docker command.

$ docker run -it centos

Once it is created, you can go to Rancher UI and see the status of the container.

Rancher - Your Private Container Service - Native Docker CLI
Rancher – Your Private Container Service – Native-Docker CLI

That’s All for now. Stay Tuned for next article on Deploying Multi-Container Application using Rancher.

You might also like