How To Set Up RancherOS And Run Containers


Are you using ubuntu or any other linux distro to run your docker containers? Well what if I tell you that there is an even more lightweight distro to utilize called RancherOS to run all your docker containers. RancherOS is considerably smaller than most conventional operating systems because it only offers the services required to run Docker. Requirements for security patches and other maintenance are also decreased by eliminating pointless libraries and services. The smallest and simplest way to run Docker in production is with RancherOS. Let's go ahead and set up Rancher OS and put it to the test.

Create Virtual Machine To Install Rancher OS

This step will differ from person to person, perhaps you want to download the RanchOS ISO and install it on a physical computer or server you can do that or on a virtual machine. For this exercise I created a virtual machine on my proxmox server. I attached the RancherOS ISO after downloading it and created the virtual machine which brings us to this boot screen.

rancheros installer

Few seconds later you will be logged into RancherOS and see the shell command line. We can run docker ps and confirm that there are no containers running like the image below.

ranchos cli

To go ahead and install RancherOS to disk we need to create a cloud-config.yml file with our ssh key in order for us to ssh to the vm after installation completes. First we are going to change the default password with sudo passwd rancher then change it to your password and then ssh to the rancher instance. Once logged in via ssh create the cloud-config.yml file and add the below code

address: #your ip here
gateway: #your network gateway here
dhcp: false
- #your name server here
- <your pub ssh key here>

Once the cloud-config.yml file is created we will run the command below to install Rancher OS to disk.

sudo ros install -c cloud-config.yml -d /dev/sda

Follow the prompts and complete the installation. once the installation completed you can ssh into the RancherOS instance via ssh and your ssh key and deploy your docker containers.

ssh -i ~/.ssh/key_rsa rancheros@{your_ip_addr}

In conclusion, RancherOS is easy to deploy and manage where you can run plenty of your docker workloads without any hassle. If you enjoyed this article consider signing up for our newsletter and don't forget to share it with people that would find it useful. Leave a comment below with a tutorial you would like us to cover.

Chad Crouch

GoLang Fanatic & FullStack Geek experienced in multiple enterprise environments. Has a huge passion for the open-source world specifically Linux and Opensource Software.