What is Docker?
Docker is a powerful and widely-used software option for creating, deploying, and running applications in containers. It's similar to a virtual machine (VM), but merely lets apps utilize the same kernel as the Linux OS Docker is running on. In that way, Docker eschews the need for an entire Linux distribution (distro) installation, whereas running apps in a VM requires first installing a base OS. Moreover, since Docker shares the Linux kernel, applications simply require whatever's not running on the host PC. Therefore, you'll witness enhanced performance with Docker.
Why Use Docker?
Ok, but why should you use Docker? Notably, Docker gained much traction in the DevOps space. For one, there's simplicity of app deployments. You won't need to fiddle with your computer and operating system to get applications to run. Plus, Docker boasts thousands of programs which are easily installed with a quick pull. There's flexibility since Docker avoids the need to run a resource-intensive VM, allowing for many containers running on a solitary machine rather than virtualization through the likes of a virtual machine.
Why you should use Docker:
- Simplicity of app installs
- Better performance when compared to VMs
- Shares OS kernel
What is the Raspberry Pi?
The Raspberry Pi is a single-board computer. Onboard, you'll find RAM, a CPU, GPU, and connectivity such as Wi-Fi, Bluetooth, and a 40-pin GPIO header. You can run a variety of operating systems on the Raspberry Pi, from Linux and Android to Chrome OS.
Raspberry Pi 3 B+ specs:
- Broadcom BCM2837B0, Cortex-A53 (ARMv8) 64-bit SoC @ 1.4GHz
- 1GB LPDDR2 RAM
- 802.11.b/g/n/ac wireless LAN, Bluetooth 4.2, BLE
- Gigabit Ethernet over USB 2.0 ( with a maximum throughput of 300 Mbps)
- 40-pin GPIO header
- 4 x USB 2.0 ports
- CSI camera port
- DSI display port
- 4-pole stereo output and composite video output
- MicroSD card slot
- 5V/2.5A DC power input
- Power-over-Ethernet (PoE) support (separate PoE HAT required)
Which Raspberry Pi Should You Use for Docker?Raspberry Pi boards come in a variety of flavors. There's the $5 USD Raspberry Pi Zero, Raspberry Pi Zero W for Internet of Things (IoT) applications and wireless networking, Raspberry Pi 3 A+, and Raspberry Pi 3 B+. I recommend using a Raspberry Pi 3 Model B or Raspberry Pi 3 Model B+. This will allow for better Docker performance since the Pi 3 and Pi 3B+ touts the most RAM at 1GB, as well as enhanced networking for the Pi 3 B+.
Raspberry Pi Docker Installation and UseRunning Docker on the Raspberry Pi is pretty simple, and requires little more than a Pi board, compatible Linux operating system, and a few Raspberry Pi accessories. You'll need a Raspberry Pi board (Raspberry Pi 3 or Raspberry Pi 3 B+ recommended), compatible 5V/2.5A power supply (PSU), and microSD card. On the software side, Docker on the Raspberry Pi necessitates a Raspberry Pi-compatible Linux distro and Docker software. You'll also need an Internet connection, and though a case isn't required, I strongly suggest copping a fun Raspberry Pi case. Plus, you'll need a few peripherals including a keyboard and mouse.
What you'll need to run Docker on Raspberry Pi:
- Raspberry Pi 3/Raspberry Pi 3 B+ board
- microSD card
- Case (optional, recommended)
- Linux OS
- Peripherals (keyboard, mouse)
- Internet connection
- 5V/2.5A PSU
Begin by opening up a command line (CTRL + ALT + T) and installing Docker. To begin the Docker installer, run:
curl -sSL https://get.docker.com | shYou might prefer to use the Docker testing version. If so, merely replace get.docker.com with test.docker.com which will look like:
curl -sSL https://test.docker.com | shNow, Docker should be installed. You'll want to make a few manual configurations before using Docker on the Pi. To auto-start Docker, in a command prompt enter:
sudo systemctl enable dockerThen, reboot or start the Docker daemon using:
sudo systemctl start dockerAfter that, we'll need to enable the Docker client, since only root or members of a Docker group may run Docker on the Pi:
sudo usermod -aG docker piHowever, you might wish to run Docker without entering
sudoevery time. To run Docker without
sudo, first add the Docker group:
sudo groupadd dockerThen, create a connected user for your Docker group. You can change this user name if you'd rather not use the current user:
sudo gpasswd -a $USER dockerNext, to manifest your changes, run:
newgrp dockerTest that Docker is properly working by entering:
docker run hello-worldIf everything went as planned, you should see the message "Hello from Docker!" along with some basic information.
How to Install Docker Images on Raspberry Pi - Plex in Docker on Raspberry Pi TestWith Docker correctly installed on the Raspberry Pi, you can begin installing apps in Docker. I did a quick test with the official Plex Media Server Docker image. First, make sure that if your media folder is accessible in Docker. If you're using an external drive, you'll need to mount it. To find out what storage device that is, in a command line run:
df -hYou'll see an output of your filesystem, and the device at /media/pi should be the correct one. Often, that's /dev/sda1. Make a directory, and mount that drive. You can use whatever folder name you like, but I used "Plex media":
mkdir /mnt/Plex mediaThen, with that directory created, mount your external storage device:
mount /dev/sda1 /mnt/Plex mediaGrant read/write access with:
chmod 775 /mnt/Plex mediaDownload the Plex Docker image, Note that this is an ARMHF version of Plex from LinuxServer.io. The official Plex Docker image won't run on the Raspberry Pi since it's ARM-based:
docker pull lsioarmhf/plexThen, create your Raspberry Pi Docker Plex set up. You'll want to specify the folders for your media, which will vary based on your specific configuration:
docker create \If you used the aforementioned mount path, use /mnt/Plex media with corresponding movies and TV show folders, your set up will look like:
-e PUID=<UID> -e PGID=<GID> \
-v </path/to/library>:/config \
-v <path/to/tvseries>:/data/tvshows \
-v </path/to/movies>:/data/movies \
-v </path for transcoding>:/transcode \
docker create \Test that everything worked with:
-e PUID=<UID> -e PGID=<GID> \
-v /mnt/Plex media:/config \
-v /mnt/Plex media:/data/tvshows \
-v /mnt/Plex media:/data/movies \
-v /mnt/Plex media:/transcode \
docker ps -aYou should see any Docker containers you've got running. If you've got a Plex container, then enter:
docker start plexAfter that, an output should display which shows your status and uptime for the Docker Plex image. Open a web browser and navigate to [Raspberry Pi IP address]:32400/web. You should see the Plex Media Server configuration screen, where you'll walk through some set up for adding folders, naming your server, and more.
Getting Started With Docker on Raspberry Pi: Final ThoughtsOverall, Docker on the Raspberry Pi is pretty simple. It's not terribly difficult, but you will need to follow path information correctly. Although Docker running on the Raspberry Pi performs well, you'll need to use images compatible with ARM devices. For instance, the official Plex Docker image won't run on the Pi. Instead, you'll need to use an ARM release for the Pi. Still, it's not a difficult process, and you'll find loads of ARM-compatible Docker images. For a lightweight, flexible Docker configuration, the Raspberry Pi is a fantastic choice. With images like Plex and Nextcloud, the Pi could make for a solid media or file server when paired with Docker.
Have you tried Docker on the Raspberry Pi? What Docker images are you using, and what devices are you running Docker on?