Air Gap Installation of single node Rancher

Vineet Kumar
3 min readJan 9, 2022

Rancher is a complete software stack for teams adopting containers. It addresses the operational and security challenges of managing multiple Kubernetes clusters, while providing DevOps teams with integrated tools for running containerized workloads.

1. Private Docker Registry: To Push rancher images to that registry from machine-1. (Ref:
2. A machine-1 which has private registry access as well as internet access so that download all required images on this machine
3. A machine-2 which has no internet access but ability to access mentioned docker private registry and deploy renacher on this node.
Note : In this article going to install rancher v:2.5.5
(Please check host entry of private registry server on both machines i.e. machine-1 and machine-2)

2. Got to the rancher release link which you want to install in this article going to install rancher:v2.5.5 so open the following link

Form above link download three files

rancher-images.txtThis     file contains a list of images needed to install Rancher,     provision clusters and user Rancher tools.rancher-save-images.shThis     script pulls all the images in the rancher-images.txt from     Docker Hub and saves all of the images as rancher-images.tar.gz.rancher-load-images.shThis     script loads images from the rancher-images.tar.gz file     and pushes them to your private registry.

3. Save the images to your workstation i.e. machine-1:
Make an executable:
chmod +x
Run with the rancher-images.txt image list to create a tarball of all the required images:
./ --image-list ./rancher-images.txt
Result: Docker begins pulling the images used for an air gap install. Be patient. This process takes a few minutes. When the process completes, your current directory will output a tarball named rancher-images.tar.gz. Check that the output is in the directory.

4. Populate the private registry :
The rancher-images.txt is expected to be on the workstation (machine-1) in the same directory that you are running the script. The rancher-images.tar.gz should also be in the same directory.

Log into your private registry if required: plain docker login <REGISTRY.YOURDOMAIN.COM:PORT>
Make an executable:
chmod +x
Use to extract, tag and push rancher-images.txt and rancher-images.tar.gz to your private registry:
./ --image-list ./rancher-images.txt --registry <REGISTRY.YOURDOMAIN.COM:PORT>

5. Following methods to install rancher
Now can install direct with single command without bind mount any file so load all images on local machine and run following commands

docker run -d --restart=unless-stopped --privileged --name rancher -p 80:80 -p 443:443 rancher/rancher:v2.5.5

In above method if container will restart then all data will destroy and if you bind mount the directory so container will search for registry server so first creates registries.yaml file on machine-2 which is as below and then install rancher on that machine

- ""
username: xxxxxx # this is the registry username
password: xxxxxx # this is the registry password
/etc/rancher/k3s/cert.pem # path to the cert file used in the registry
/etc/rancher/k3s/abc.key # path to the key file used in the registry
/etc/rancher/k3s/ca.pem # path to the ca file used in the registry

now run run the following command to run rancher

docker run -d --restart=unless-stopped --privileged --name rancher --add-host <REGISTRY.YOURDOMAIN.COM:IP> -p 80:80 -p 443:443 -v /opt/rancher:/var/lib/rancher -v /home2/k3s:/etc/rancher/k3s <REGISTRY.YOURDOMAIN.COM:PORT>/rancher/rancher:v2.5.5

NOTE: cert files and registries.yaml file must resides in /home/k3s directory and pull image should mentioned with private registry (<REGISTRY.YOURDOMAIN.COM:PORT>/rancher/rancher:v2.5.5) and host entry must require .


By docker-compose file. Create docker-compose.yaml

version: '3'services:
image: <REGISTRY.YOURDOMAIN.COM:PORT>/rancher/rancher:v2.5.5
restart: always
privileged: true
- "80:80"
- "443:443"
- /opt/rancher:/var/lib/rancher
- /home2/harbor/secrets:/etc/rancher/k3s

6. References:

7. Enjoy !!!