Archival Notice
This guide was written for legacy Rancher v2.6 deployments running inside standalone Docker containers on CentOS 7. Please note that CentOS 7 has reached End of Life (EOL), and modern production Rancher releases should be installed via Helm charts onto dedicated Kubernetes clusters rather than standalone Docker containers. Please refer to official vendor documentation for current deployment specifications.
While initializing Kubernetes clusters via kubeadm provides an excellent starting foundation, managing multiple clusters, RBAC permissions, and multi-tenant workloads purely through kubectl can become incredibly complex.
Rancher is an industry-leading open-source Kubernetes management platform that provides an elegant web-based user interface, centralized IAM integrations, and automated cluster provisioning across multiple cloud providers and bare-metal servers.
In this guide, I will walk you through preparing a CentOS 7 management node, installing Docker CE, deploying Rancher inside a privileged Docker container, and binding persistent storage volumes.
Prerequisites
You will need a dedicated CentOS 7 virtual machine (central-dc1-k8s-rancher.induslevel.com) with root privileges, configured with static IP addressing and a minimum of 4 GB of RAM.
Step 1: Base System Preparation and Host Resolution
First, update system packages, install necessary utilities, and configure local hostname resolution across your cluster nodes.
# Update system packages
yum update -y
# Install required system utilities
yum install epel-release yum-utils bash-completion net-tools device-mapper-persistent-data lvm2 -y
# Enforce static hostname resolution
cat >> /etc/hosts << "EOF"
10.14.7.51 central-dc1-k8s-master.induslevel.com k8s-master
10.14.7.53 central-dc1-k8s-node01.induslevel.com k8s-node01
10.14.7.54 central-dc1-k8s-node02.induslevel.com k8s-node02
10.14.7.55 central-dc1-k8s-rancher.induslevel.com k8s-rancher
EOF
Step 2: Disabling Swap and SELinux
Rancher and underlying Kubernetes components require swap memory to be entirely disabled. We also disable SELinux to allow unhindered container network bridging.
# Disable SELinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
# Turn off active swap and remove fstab mounting
swapoff -a
sed -i.bak -r 's/(.+ swap .+)/#\1/' /etc/fstab
# Verify configuration
free -m
cat /etc/fstab
Reboot the virtual machine to apply the clean kernel baseline:
reboot
Step 3: Installing Docker CE
Rancher runs as a containerized application. Configure the official Docker CE repository and install the Docker engine.
# Configure Docker CE repository manifest
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# Install Docker engine
yum install -y docker-ce docker-ce-cli containerd.io
# Enable and start Docker daemon
systemctl enable docker
systemctl start docker
systemctl status docker
Step 4: Deploying Rancher Server Container
With Docker operational, create a persistent host directory to store Rancher configuration data and deploy the Rancher server container in privileged mode.
# Create persistent storage directory
mkdir -p /opt/rancher
# Deploy Rancher server container
docker run -d --restart=unless-stopped -p 80:80 -p 443:443 -v /opt/rancher:/var/lib/rancher --privileged rancher/rancher
Understanding the Deployment Parameters
--restart=unless-stopped: Ensures Rancher automatically restarts if the Docker daemon or server reboots.-p 80:80 -p 443:443: Exposes standard HTTP and HTTPS web management ports.-v /opt/rancher:/var/lib/rancher: Binds persistent storage so cluster configurations survive container updates.--privileged: Grants Rancher necessary kernel capabilities to manage embedded Kubernetes components.
Rancher Management Platform Online
Your Rancher server is now initializing! Open your browser and navigate to https://central-dc1-k8s-rancher.induslevel.com to set up your administrative password and import your first Kubernetes cluster!