ResinOS: step up your container game on Raspberry PI

Docker Logo

In the past we’ve seen how to install Docker on a Raspberry PI using the native Raspbian operating system. Today let’s take a look at a more advanced option: ResinOS.

Why ResinOS?

ResinOS is a lightweight operating system tailored for containers that runs on a variety of ARM boards. It is essentially an operating system that enables you to run Docker containers on your ARM board out of the box, no complex Docker installations. Everything is already set up for you and you also have a nifty command-line called resin-cli that will help you from the early stage of setting up your board, to the final stages such as deploying your project.

On top of that since version 2.9.0, ResinOS uses balena.io as an alternative Container Engine. Balena is a container engine optimized for low-memory device such as ARM boards. It uses less memory, uses image deltas by default (read: no need to re-download huge layers) and prevents pesky pitfalls such as corrupted layers due to power failures and similar events. Balena should essentially be the same as the Docker Engine but there are a few features missing such as Docker Swarm.

Installing Resin-cli (optional, recommended)

Important
I take absolutely NO responsibility of what you do with your machine; use this tutorial as a guide and remember you can possibly cause data loss if you touch things carelessly.

Without further discussion let’s dive into the first step: installing resin-cli. In this step you will install resin-cli on your machine, not the target machine for ResinOS. This step is by no mean required, but it will simplify your life a lot.

First let’s talk about requirements:

If you have all the requirements you can simply do:

$ npm install --global --production --unsafe-perm resin-cli

Getting and configuring the image (resin-cli)

$ wget https://files.resin.io/resinos/raspberrypi3/2.15.1%2Brev2.dev/image/resin.img.zip
$ unzip resin.img.zip

Now that you got the image you configure it using the resin-cli:

$ sudo resin local configure ~/Downloads/resin.img
? Network SSID super_wifi
? Network Key super secure password
? Do you want to set advanced settings? Yes
? Device Hostname resin
? Do you want to enable persistent logging? no
Done!

Configuring the image (without resin-cli)

If you don’t want to use the resin-cli, you can simply mount the image or burn the image on a micro SD card and modify the following files:

/boot/config.json:

{
  "persistentLogging": false,
  "hostname": "resin",
}

/boot/system-connections/resin-sample:

[connection]
id=resin-sample
type=wifi

[wifi]
mode=infrastructure
ssid=I_Love_Unicorns

[wifi-security]
auth-alg=open
key-mgmt=wpa-psk
psk=superSecretPassword

[ipv4]
method=auto

[ipv6]
addr-gen-mode=stable-privacy
method=auto

Simply modify these parameters mainly related to wi-fi, in order to get the desired result. PersistentLogging is great, but it may slow down and saturate your micro SD card, hence it is advised to keep it off.

Burning the image (resin-cli)

Resin-cli makes the process of burning the image super-easy:

$ sudo resin local flash /path/to/resin.img
? Select drive /dev/disk3 (7.9 GB) - STORAGE DEVICE
? This will erase the selected drive. Are you sure? Yes
Flashing [========================] 100% eta 0s  
Validating [========================] 100% eta 0s

You can now safely remove the micro SD card and boot your Raspberry PI.

Burning the image (without resin-cli)

You can follow this guide and burn your image onto the micro SD card.

You can now safely remove the micro SD card and boot your Raspberry PI.

All done! BONUS: try your first project (resin-cli required)

In this final step you will harness the power and the usability of the resin-cli. On your machine (not on the Raspberry) do:

$ git clone https://github.com/resin-io-playground/resinos-sample
$ sudo resin local push resin.local --source .

This will pull a git repo containing a “hello world”, build the image and run it on your Raspberry Pi.

Image courtesy of mark | marksei
mark

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.