BalenaOS Raspberry Pi Installation

With its small footprint and low power draw, the Raspberry Pi provides the perfect environment for running Docker containers. I've successfully spun up Docker containers for running the likes of Plex and Emby on my Raspberry Pi. With official Docker support on the Debian-based Raspberry Pi operating system (OS) since Raspbian Jessie, running Docker on the Raspberry Pi is a breeze. For a simple Raspberry Pi Docker build, BalenaOS is a solid choice. Learn about getting started with BalenaOS in this tutorial and BalenaOS review!

What is BalenaOS?

Hailing from the folks over at Balena, the company behind open-source image writing utility Etcher, comes BalenaOS. It' an OS for devices such as the Raspberry Pi engineered for running Docker containers. The Linux-based distribution (distro) features an onus on portability. While BalenaOS runs on the Raspberry Pi, it's available for other boards as well such as the ASUS TinkerBoard, Odroid XU4, Orange Pi Zero, BeagleBone Black, and Nvidia Jeston Nano. 

BalenaOS come in a few different flavors. There's a production variant which is great for, well, production environments. The development release of BalenaOS works for developing new apps, and makes use of a speedy local mode workflow. Then, the standalone BalenaOS is a simple, stable Linux operating system for Docker use. 

What is Docker and Why Should You Use it?

Docker is a virtualization software option for simple creation, deployment, and running of applications. However, it's different than a virtual machine (VM). Whereas a virtual machine requires a self-contained guest operating system with apps running within a virtualized OS, Docker runs containerized applications on top of a host operating system. As such, it's the user environment, not a complete operating system, that's virtualized. Docker containers tend to be pretty lightweight. It's pretty easy to create, deploy, run, and destroy containers. 

Docker carries many benefits. I appreciate the flexibility that containerized apps carry, such as the low system overhead. Often, system administrators, developers, and programmers use Docker for DevOps applications. But it's also fantastic for simple home use like spinning up a media or file server. 

What is the Raspberry Pi?

The Raspberry Pi is a single-board computer (SBC), meaning all components are baked in. Onboard, the Raspberry Pi rocks a CPU, GPU, RAM, and various input/output (I/O) components such as USB ports, GPIO pins, and more. The Raspberry Pi 4 clocks in as the flagship Raspberry Pi board. It's powered by a 1.5GHz quad-core Broadcom BCM2711B0 Cortex A-72 system-on-a-chip (SoC) with a 500MHz VideoCore VI GPU. For RAM, three different Raspberry Pi boards offer a choice of 1GB, 2GB, or 4GB of LPDDR4 RAM. Networking boasts 802.11ac Wi-Fi, gigabit Ethernet, and Bluetooth 5.0. For video output, the Pi 4 touts dual micro HDMI ports with 4K capability. There's a USB-C power port, two USB 3.0 hosts, and dual USB 2.0 headers. 

The Raspberry Pi 3 B+ features a Broadcom BCM2837B0, Cortex-A53 (ARMv8) 64-bit 1.4GHz SoC, 1GB RAM, and 802.11ac Wi-Fi. Onboard, there's Bluetooth 4.2, a full-size HDMI capable of 1080p video resolution, four USB 2.0 ports, and power over Ethernet (PoE) support. 

Raspberry Pi 4 Specs:

  • Broadcom BCM2711, Quad-core Cortex-A72 (ARM v8) 64-bit SoC @ 1.5GHz
  • 1GB, 2GB or 4GB LPDDR4-2400 SDRAM (depending on model)
  • 2.4 GHz and 5.0 GHz IEEE 802.11ac wireless, Bluetooth 5.0, BLE
  • Gigabit Ethernet
  • 2 USB 3.0 ports; 2 USB 2.0 ports.
  • Raspberry Pi standard 40 pin GPIO header (fully backwards compatible with previous boards)
  • 2 × micro-HDMI ports (up to 4kp60 supported)
  • 2-lane MIPI DSI display port
  • 2-lane MIPI CSI camera port
  • 4-pole stereo audio and composite video port
  • H.265 (4kp60 decode), H264 (1080p60 decode, 1080p30 encode)
  • OpenGL ES 3.0 graphics
  • MicroSD card slot for loading operating system and data storage
  • 5V DC via USB-C connector (minimum 3A*)
  • 5V DC via GPIO header (minimum 3A*)
  • Power over Ethernet (PoE) enabled (requires separate PoE HAT)
  • Operating temperature: 0 – 50 degrees C ambient

Raspberry Pi 3 B+ specs:

  • Broadcom BCM2837B0, Cortex-A53 (ARMv8) 64-bit SoC @ 1.4GHz
  • 1GB RAM
  • 802.11 b/g/n/ac Wi-Fi
  • Bluetooth 4.2/BLE
  • Extended 40-pin GPIO header
  • HDMI
  • USB 2.0 port
  • CSI connector
  • DSI connector
  • 4-pole stereo output and composite video port
  • microSD card slot 
  • 5V micro USB power slot

How to Install BalenaOS on the Raspberry Pi

Installing BalenaOS on the Raspberry Pi is pretty easy. First, you'll need a Raspberry Pi board, optional but recommended case, microSD card, and power supply unit (PSU). The BalenaOS download is required as well. On the software side, you'll have to use a program to mount the BalenaOS image to a mircoSD card. Overall, it's an inexpensive yet functional project. 

What you'll need to build a BalenaOS Raspberry Pi installation:

  • Raspberry Pi board (Raspberry Pi 4 recommended)
  • BalenaOS download
  • Raspberry Pi case (optional, recommended)
  • Power supply
  • MicroSD card
  • Peripherals (i.e. keyboard, mouse)
  • Image mounting software (i.e. Etcher from Balena)

Total cost: $35+ USD. You can get started with BalenaOS on the Raspberry Pi with just a Raspberry Pi board, power supply, and microSD card. Since BalenaOS run on the Raspberry Pi 1, Raspberry Pi Zero, Pi 2, 3 and 3 B+, as well as Raspberry Pi 4, you have tons of options for base hardware. I suggest opting for a complete kit, but you can piece together a BalenaOS build.

BalenaOS Getting Started

First up, head over to the official BalenaOS website and download the correct image. Select the Raspberry Pi logo, then pick the image for your board, and choose from either Production or Development. 

Once the ZIP folder finishes downloading, go ahead and unzip the folder which will leave you with an IMG file. Using a program such as Etcher (thanks again Balena), mount it to a microSD card. Open up Etcher, and under Select Image pick the Balena OS image file. Then, under Target point to your microSD card. When your Balena OS Raspberry Pi IMG and microSD card boot medium are selected, click Flash. Wait for mounting to finish, then pop the microSD card into your Raspberry Pi device and power it on. 

Balena Cloud Installation

Alternatively, head over to the Balena Cloud site. Create a free account (you can log in with GitHub or Google). Once you've logged in, click Create application

Next, give your application a name. Choose the device type, in this case a Raspberry Pi board (you'll need to select the correct version, i.e. Raspberry Pi 3 or Raspberry Pi 4). Finally, input the application type, Starter, Essentials, or Microservices. When everything looks correct, choose Create new application

Then, select Add Device. Choose your board and preferred BalenaOS version. Pick the development or production edition. Opt for Ethernet only or WiFi and Ethernet. Then, download BalenaOS and proceed to mount the image file, pop it in your Pi, connect to the Internet, and your device should appear in your Balena Cloud dashboard.  

BalenaOS Running on the Raspberry Pi

Once you've booted into BalenaOS, it's time to configure it with another device. Since it's meant to run headless, you won't really be able to perform any functions on your Pi.

Go ahead and download the Balena CLI (command line interface). You can pick from the executable installer, standalone ZIP package, or NPM installation. I opted for the Windows 10 EXE installer. After downloading the executable, I ran the installer. After that, I opened a command prompt (type CMD into your search bar). 

First, check that your device is online. In a command line, enter:

ping mydevice.local

You should see ping information appear.

Next, you can SSH into Balena with:

balena ssh mydevice.local

After SSHing into your Balena installation, you can clone a demo project for a sample container. To accomplish this, merely SSH into your Raspberry Pi Balena OS installation and run:

git clone https://github.com/balena-io-projects/multicontainer-getting-started.git

If you want to launch containers, you'll use:

balena push mydevice.local

The push command refers to images in either your DockerFile or docker-compose.yml.

To create a new app container, first enter (where sampleapp is whatever name you want to give your directory):

mkdir -p sampleapp && touch Dockerfile

Then, create a container:

FROM balenalib/raspberrypi3-64-ubuntu-node

CMD ["/etc/os-release"]

The FROM portion specifies the Docker container to base it on. The CMD section merely states what the container runs upon startup. You can customize this as you like. Then, to get that app running, enter:

balena push mydevice.local

BalenaOS Review: Should You Use BalenaOS on the Raspberry Pi?

Overall, BalenaOS is a pretty easy means of spinning up Docker containers on the Raspberry Pi. It's lightweight, runs headless, and is extremely well documented. There are tons of Balena containers to pull for a variety of boards. Aside from the standard installation, there's Balena Cloud for a pretty easy means of installing Balena. If you don't plan to run headless and require a graphical user interface (GUI), BalenaOS isn't for you. But if you're simply looking for an easy method of spinning up Docker containers on the Pi, BalenaOS is a great pick that just works. 

Leave your feedback...