Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Install Rancher on CentOS 7

Install Docker, then run Rancher in a container and open its web interface.

VPS and Cloud Servers2 min read3 steps8 screenshots
Note: CentOS 7 has reached its end of life. The same steps work on AlmaLinux or Rocky Linux, which are better choices for new servers.

What you need

  1. A CentOS 7 server with root or sudo access.
  2. At least 2 CPU cores and 4 GB of RAM.
  3. Internet access to download the packages.

Step 1: Update the system

sudo yum update -y && sudo reboot
Updating and rebooting

Step 2: Install Docker

Install the required tools:

sudo yum install -y yum-utils device-mapper-persistent-data lvm2
Installing the dependencies

Add the Docker repository:

sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Adding the Docker repository

Install Docker:

sudo yum install -y docker-ce
Installing Docker

Start Docker and enable it at boot:

sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker
Docker is running

Check the version:

docker --version

Step 3: Install Rancher

Pull the image:

sudo docker pull rancher/rancher:latest
Pulling the Rancher image

Run the container (it uses ports 80 and 443, and --privileged is needed by current versions):

sudo docker run -d --restart=unless-stopped --privileged -p 80:80 -p 443:443 rancher/rancher:latest
Deploying Rancher

Wait a minute or two for Rancher to start.

Step 4: Open the Rancher interface

Go to this address in your browser:

https://<your-server-ip>/

The certificate is self-signed at first, so your browser shows a warning. Continue.

Step 5: Set up Rancher

Rancher asks for the bootstrap password. Find it in the container log:

sudo docker logs <container_id> 2>&1 | grep "Bootstrap Password:"

Use sudo docker ps to find the container ID. Enter the password, then set a new admin password and confirm the server URL.

The Rancher interface

After that you can create or import Kubernetes clusters in Rancher.

Quick recap

  • Install Docker.
  • docker run ... rancher/rancher starts Rancher.
  • Open the server over HTTPS and use the bootstrap password from the log.