How to Install Rancher on CentOS 7

September 22, 2020


Install Rancher on CentOS, a container management platform used by virtualization vendors with Kubernetes in their standard infrastructure. The software simplifies deploying, running, and managing Kubernetes at scale.

In this tutorial, you will learn how to install Rancher on CentOS and get started with the basic configuration.

How to install Rancher on CentOS.


  • A CentOS system
  • Access to a command line/terminal
  • A user account with sudo or root privileges
  • Multiple nodes you can use for your cluster

Install Rancher on CentOS

Step 1: Installing Docker

1. Update the system by running:

sudo yum check-update

2. Uninstall old Docker versions with:

sudo yum remove docker docker-engine

3. Download the dependencies:

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

Wait for the process to finish until you see the dependencies have installed.

Download Docker dependencies on CentOS.

4. Add the official Docker repository:

sudo yum-config-manager --add-repo

5. Now install Docker by running:

sudo yum install docker-ce

How to Solve Docker Installation Error

You may get an ERROR saying the system cannot install docker-ce because it requires

Output showing Docker cannot install on CentOS.

To solve this problem, install manually by running:

yum install -y

Now, repeat the Docker installation command:

sudo yum install docker-ce

Step 2: Enabling the Docker Service

1. Start the Docker service and enable it to run on boot:

sudo systemctl start docker
sudo systemctl enable docker

2. Then, check the service status:

sudo systemctl status docker

The output should display the service is active (running).

Start Docker service on CentOS.

Step 3: Installing Rancher

1. Launch the Rancher server inside a Docker container with the command:

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

Docker pulls the latest stable Rancher image and launches the container. The command above runs the container in detached mode (-d) and keeps it running (--restart=always) listening to port 8080.

Launch Rancher on CentOS.

Note: Learn more about the docker run command and the many different ways to run a container by checking out How To Use Docker Run Command With Examples.

2. Check whether the Rancher server is running by listing existing docker containers in running state:

docker ps

You should see the Rancher container listed in the output.

Verify Rancher container is running.

3. Now you can open the Rancher user interface by navigating to the server IP number and port in the URL bar.

Launch Rancher interface on CentOS.

Configuring Rancher

The basic Rancher configuration outlined in the steps below will help you create an admin user and launch a Kubernetes cluster.

Step 1: Setting Up Admin User

This first thing to do after launching Rancher is to set up the Admin user.

1. Click the ADMIN drop-down menu and select Access Control.

Configure Rancher on CentOS.

2. Select LOCAL configuration to move to the Local Authentication window.

Select LOCAL configuration from the access control menu.

3. Fill in the required information to set up an Admin user. Then, click Enable Local Auth to confirm.

Set up an Admin User for Rancher.

Step 2: Provisioning a Host

1. Select the INFRASTRUCTURE drop-down menu and click HOSTS.

2. Start up the machine making sure it has a supported version of Docker and allows traffic to and from hosts on ports 500 and 4500.

3. Add the IP address of the host.

4. Copy and paste the generated command in the terminal window of the machine.

5. Close and wait for the new host to appear on the Host screen.

Step 3: Creating a Custom Kubernetes Cluster

1. Open the Clusters page and select Add Cluster.

2. Choose Custom, provide a Cluster Name, and click Next.

3. Choose what roles you want the nodes to have (etcd, Control Plane, and/or Worker) from the Node Options.

4. Copy and paste the generated command on each worker node machine. Each machine within the cluster must have a supported version of Docker installed. Finally, wait for the cluster to start up.

Note: Refer to our in-depth guide How to Set Up a Kubernetes Cluster with Rancher for more details on managing clusters with Rancher.


After reading this article, you should have successfully installed a Rancher server within a Docker container.

When setting up Kubernetes clusters, make sure to secure your workloads. To learn more about how to do so, refer to Kubernetes Security Best Practices.

Was this article helpful?
Sofija Simic
Sofija Simic is an experienced Technical Writer. Alongside her educational background in teaching and writing, she has had a lifelong passion for information technology. She is committed to unscrambling confusing IT concepts and streamlining intricate software installations.
Next you should read
How to Install Rancher on Ubuntu
September 2, 2020

Install Rancher on your Ubuntu server and get started using this container management platform that helps...
Read more
How to Restart Kubernetes Pods
November 27, 2023

Kubernetes is one of the premier systems for managing containerized applications. But it isn't always able to...
Read more
How to Update Docker Image and Container to the Latest Version
July 11, 2024

To avoid running containers with outdated Docker images, update the image and run the container with the...
Read more
How to Install Jenkins on Kubernetes Cluster
March 3, 2020

Use a provided set of YAML files to deploy scalable Jenkins on Kubernetes in 4 easy steps. Use Jenkins to...
Read more