Nov 18, 2022 2 min read

How To Set Up RancherOS And Run Containers

How to set up RancherOS, a lightweight docker host and alternative to other docker operating systems.

How To Set Up RancherOS And Run Containers
Table of Contents

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 And 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

A 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 in 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 the 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

#cloud-config
 
rancher:
network:
interfaces:
eth0:
address: 192.168.1.50/24 #your ip here
gateway: 192.168.2.1 #your network gateway here
dhcp: false
dns:
nameservers:
- 192.168.2.1 #your name server here
- 8.8.8.8
 
ssh_authorized_keys:
- <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}

Conclusion

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.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Opensource Geeks.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.