This guide covers installing Rancher on a single Linux host with one docker run command. It walks through all four TLS options: Rancher's built-in self-signed certificate, your own self-signed certificate, a CA-signed certificate and Let's Encrypt. It also fills in what the steps above leave out: installing Docker, keeping data persistent, getting the bootstrap password, checking that the install worked, upgrading and fixing common errors.
Step 1 – Install Docker
Step 2 – Choose an SSL Option and Install Rancher
Choose from the following options:
- Option A: Default Rancher-generated Self-signed Certificate
- Option B: Bring Your Own Certificate, Self-signed
- Option C: Bring Your Own Certificate, Signed by a Recognized CA
- Option D: Letโs Encrypt Certificate
Step 3 – Option A: Default Rancher-generated Self-signed Certificate
docker run -d --restart=unless-stopped \
-p 80:80 -p 443:443 \
--privileged \
rancher/rancher:latest
Reference:
- https://rancher.com/docs/rancher/v2.6/en/installation/other-installation-methods/single-node-docker/
When a single-node Docker install makes sense
Running Rancher as one Docker container is the fastest way to get the Rancher UI and API up. It suits labs, demos, training and short-lived test environments. The container runs an embedded lightweight Kubernetes (K3s) internally, so it needs the --privileged flag.
Note: Rancher does not recommend the Docker install for production. There is no high availability, and you cannot move a Docker install onto a Kubernetes cluster later. For production, install Rancher with Helm on a dedicated Kubernetes cluster (K3s or RKE2) with at least three nodes.
Prerequisites
- A 64-bit Linux host (VM or bare metal). Plan for at least 2 vCPUs and 4 GB of RAM. Rancher becomes slow or unstable with less.
- A Docker Engine version listed as supported in the support matrix for the Rancher version you plan to run.
- Inbound TCP ports 80 and 443 open to your browser, and to any downstream cluster nodes that will register with Rancher.
- A DNS name for the host. Options C and D need one. It is also recommended for A and B, because downstream clusters store the Rancher server URL.
- Do not run Rancher on a host that is also a node of a cluster Rancher manages.
Step 1 in detail: install Docker
Step 1 above has no commands. On most distributions, Docker's convenience script installs Docker Engine. In production-like environments, use your distribution's packages or Docker's official repository, and pin a version that Rancher supports.
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo systemctl enable --now docker
# Optional: run docker without sudo (log out and back in afterwards)
sudo usermod -aG docker $USER
# Verify
docker version
docker run --rm hello-worldCode language: PHP (php)
Corrected and complete install commands for all four SSL options
The example above shows only Option A, and it stores Rancher's data inside the container. If you remove that container, you lose every user, cluster registration and setting. Each command below adds three things: --name rancher so the container is easy to manage, a bind mount -v /opt/rancher:/var/lib/rancher so data survives container replacement, and a pinned image tag instead of latest. Replace v2.X.Y with the exact release you have chosen from the Rancher releases page.
Option A: Rancher-generated self-signed certificate. Use this for quick labs. Browsers will show a certificate warning.
docker run -d --restart=unless-stopped \
--name rancher \
-p 80:80 -p 443:443 \
-v /opt/rancher:/var/lib/rancher \
--privileged \
rancher/rancher:v2.X.YCode language: JavaScript (javascript)
Option B: your own self-signed certificate. Mount the full-chain certificate, the private key and the CA certificate that signed them. All three must be PEM-encoded.
docker run -d --restart=unless-stopped \
--name rancher \
-p 80:80 -p 443:443 \
-v /opt/rancher:/var/lib/rancher \
-v /etc/rancher-certs/fullchain.pem:/etc/rancher/ssl/cert.pem \
-v /etc/rancher-certs/privkey.pem:/etc/rancher/ssl/key.pem \
-v /etc/rancher-certs/ca.pem:/etc/rancher/ssl/cacerts.pem \
--privileged \
rancher/rancher:v2.X.YCode language: JavaScript (javascript)
Option C: certificate signed by a recognized CA. Mount the certificate and key, and pass --no-cacerts after the image name so Rancher does not generate its own CA. The certificate file should contain the full chain, including intermediates.
docker run -d --restart=unless-stopped \
--name rancher \
-p 80:80 -p 443:443 \
-v /opt/rancher:/var/lib/rancher \
-v /etc/rancher-certs/fullchain.pem:/etc/rancher/ssl/cert.pem \
-v /etc/rancher-certs/privkey.pem:/etc/rancher/ssl/key.pem \
--privileged \
rancher/rancher:v2.X.Y \
--no-cacertsCode language: JavaScript (javascript)
Option D: Let's Encrypt. Pass --acme-domain with a public DNS name that resolves to this host. Port 80 must be reachable from the internet, because Let's Encrypt validates over HTTP. Do not remap port 80 to another port with this option.
docker run -d --restart=unless-stopped \
--name rancher \
-p 80:80 -p 443:443 \
-v /opt/rancher:/var/lib/rancher \
--privileged \
rancher/rancher:v2.X.Y \
--acme-domain rancher.example.comCode language: JavaScript (javascript)
| Flag or argument | Purpose |
|---|---|
--restart=unless-stopped | Starts Rancher again after a reboot or crash unless you stopped it yourself |
-p 80:80 -p 443:443 | Publishes HTTP (redirects to HTTPS) and HTTPS on the host |
-v /opt/rancher:/var/lib/rancher | Keeps Rancher's embedded datastore on the host so it survives container replacement |
--privileged | Required because Rancher runs embedded K3s inside the container |
--no-cacerts | Option C only: tells Rancher the certificate comes from a public CA |
--acme-domain | Option D only: requests and renews a Let's Encrypt certificate for that name |
Note: To set the first admin password yourself instead of using a generated one, add -e CATTLE_BOOTSTRAP_PASSWORD='YourStrongPassword' before the image name.
Log in for the first time
Rancher takes a minute or two to start. Since Rancher 2.6, a random bootstrap password is generated on first start and written to the container log. The steps above do not mention this, but you need it to log in.
- Follow the logs until startup settles:
docker logs -f rancher - Get the bootstrap password:
docker logs rancher 2>&1 | grep "Bootstrap Password:" - Open
https://<your-host-or-dns-name>in a browser. With Options A and B, accept the certificate warning. - Enter the bootstrap password, set a strong admin password, and confirm the Server URL. Downstream cluster nodes use this URL to reach Rancher, so it must be a stable name or IP they can resolve and reach.
# Quick health checks
docker ps --filter name=rancher
curl -k https://localhost/ping
# Expected output:
# pongCode language: PHP (php)
Common errors and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
bind: address already in use on port 80 or 443 | Another web server (Nginx, Apache, Traefik) already owns the port | Stop that service, or publish different ports such as -p 8080:80 -p 8443:443 and browse to https://host:8443. This does not work with Option D. |
| Container restarts repeatedly and the logs mention privileged mode | --privileged was omitted | Remove the container and run it again with --privileged |
| Container restarts and the logs show K3s or cgroup errors | Host kernel, cgroup or Docker version not supported by this Rancher release | Check the support matrix and use a supported OS, Docker and Rancher combination |
| Let's Encrypt certificate never issues | DNS does not point to the host, or port 80 is blocked from the internet | Check with dig rancher.example.com and open port 80 in firewalls and security groups |
| Browser warns about the certificate with Option C | Intermediate certificates are missing from cert.pem | Concatenate the server certificate and intermediates into one full-chain file |
| All settings lost after recreating the container | No volume was mounted for /var/lib/rancher | Always mount a host path or named volume, as shown above |
grep finds no bootstrap password | Startup has not finished, or the data directory already contains an initialized install | Wait and check the logs again. If the data directory is reused, log in with the existing admin password. |
Upgrading and backing up
With data in /opt/rancher, an upgrade means stopping the old container, backing up the directory and starting a newer image against the same data. Upgrade one supported minor version at a time and read the release notes first. Rolling back means restoring the backup; you cannot simply start an older image against upgraded data.
docker stop rancher
sudo tar czf /root/rancher-backup-$(date +%F).tar.gz -C /opt rancher
docker rm rancher
docker pull rancher/rancher:v2.X.Z
docker run -d --restart=unless-stopped \
--name rancher \
-p 80:80 -p 443:443 \
-v /opt/rancher:/var/lib/rancher \
--privileged \
rancher/rancher:v2.X.ZCode language: JavaScript (javascript)
Note: Include the same certificate mounts and arguments (--no-cacerts or --acme-domain) in the new docker run that you used originally.
Security best practices
- Pin an exact image tag.
latestcan pull a new minor version on the next restart or recreate and trigger an untested upgrade. - Limit access to port 443 with firewall rules or security groups. A privileged container is effectively root on the host.
- Use Option C or D for anything other people will use, so users do not learn to click through certificate warnings.
- Change the bootstrap password immediately, and set up an external identity provider (LDAP, SAML or OIDC) instead of sharing the local admin account.
- Protect
/opt/rancherand your certificate files with root-only permissions, and back them up regularly.
Frequently asked questions
Why does Rancher need the –privileged flag in Docker?
Since Rancher 2.5, the container runs an embedded K3s Kubernetes cluster to host Rancher itself. K3s needs privileged access to manage cgroups, networking and mounts, so the container will not start correctly without the flag.
How do I find the Rancher bootstrap password?
Run docker logs <container> 2>&1 | grep "Bootstrap Password:" after the container has started. You can also set the password in advance with -e CATTLE_BOOTSTRAP_PASSWORD=... in the docker run command.
Can I run Rancher on ports other than 80 and 443?
Yes. Publish other host ports, for example -p 8080:80 -p 8443:443, and browse to the HTTPS port you chose. This does not work with the Let's Encrypt option, because HTTP validation needs port 80.
Is a single-node Docker install of Rancher suitable for production?
No. It has no high availability, and it cannot be migrated to a Kubernetes-based install. For production, install Rancher with Helm on a multi-node K3s or RKE2 cluster.
How do I keep Rancher data when the container is removed?
Mount /var/lib/rancher to a host directory or named volume, for example -v /opt/rancher:/var/lib/rancher. Without the mount, the data lives only in the container's writable layer and is deleted along with the container.
Related tutorials
- Docker commands Guide โ docker run with examples
- Docker Lab, Excercise & Assignment โ 7 โ Docker Volume
- Docker commands Guide โ docker network with examples
- What is Docker and use cases of Docker?
- More Docker tutorials
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services โ all in one place.
Explore Hospitals