Raspberry Install Docker

/ Comments off

We were eager to test and use Docker in our Raspberry Valley makerspace. This document describes how to setup a base image for your Docker experiments.

Docker for the Raspberry Pi has support for Raspbian Jessie, Stretch, and Buster. Installing Docker to the Raspberry Pi. Thanks to a nifty install script developed by the Docker team, installing the container software is incredibly simple. You can even complete the following steps by using an SSH connection to your Raspberry Pi. Add user pi to the Docker Group. By default, only users with administrative rights (root users) can run containers. If you are not logged in as root, one option is to use the sudo prefix. However, you could also add your non-root user to the Docker group, which allows him to run Docker commands. This command adds the default user pi to.

While working with Docker images and containers on an ARM device still has some issues to handle as opposed to mainstream hardware, the installation of a bare-bones machine with Docker on top is quite straightforward.

Here is how.

Installing Docker on Raspberry Pi

  • First, setup a standard Raspbian (Lite) on your SD card. We have a dedicated article found here: Setup SD Card. Basically, please setup a Raspberry Pi Headless Device, up to the point of Flashing Raspbian Lite from here, flashing it to your device, enabling SSH, configuring via Raspi-Config and connecting headless. Ignore the remaining steps in our tutorial, we will handle the differences here
  • Update all (see our recipe Updating Raspberry Pi)
  • [optional] Install Samba: you want to do this if you want to connect to your Pi from a Windows notebook to eliminate all the hassle of setting up sharing, making hostnames visible etc.
  • install Git: We have a GIT recipe available if you want to know the details, it basically boils down to the command below. There is a good reason for having GIT sitting on your device: you will be downloading Docker software and other code often. Git is typically installed on basic distros of Raspbian, however the below won't hurt:
  • Finally, install and configure Docker
Raspberry Install Docker

You'll end up with a summary of Docker version info after installation, as seen below:

and setup your Pi to have access to the Docker daemon

  • Reboot

Docker-Compose on Raspberry Pi


Docker-Compose comes automatically with Docker on Windows, Linux etc. Not on Raspberry Pi. You can however install it anyway. This guide is based on a blog post by Alessandro Segala - Yes, you can run Docker on Raspbian.

To install Docker Compose, you have several options. For the makers here at Raspberry Valley, we chose the easiest approach: Install via pip. Simply run the following:

Points of Interest

This section list things we had to solve during our experiments, and which might speed up your own development.

Docker on Jetson Nano

If you have purchased the jetson Nano, it might come in handy to know that Docker is already installed on the Ubuntu base image. Here are a few observations for using this release.

  • First, setup Docker to run without sudo: the Jetson requires to run Docker with priviliged access, which is sort of annoying. Just type the following to use Docker as you use it on your Pi (remeber to substitute your_username with the correct value)
Raspberry Install DockerRaspberry Install Docker

Once done, logout and login again to your terminal session.

  • Update Docker: you might want to also update your Jetson Nano Docker to the latest version

GPIO vs. Docker Containers

You might find out that, if you launch a container which wants to interact with GPIO, you will get a bunch of error messages. Due to the concept of isolation of containers, this makes sense. Please read up a bit more on the subject (and how to circumvent the issue) here: Controlling GPIO with Docker Swarm.

Raspberry Zero Install Docker

If you wish to interact with your GPIO, you basically need to lauch your container in privileged mode. For example:

See what you can do with Docker on a practical recipe on our site: IoT Raspberry Pi Device on Docker. Check the links below for other inspiration - there's plenty of great material available.

  • Docker Blinkt Workshop (Alex Ellis) - a great tutorial if you want to get started with Docker on the Pi, using Blinkt. We tried it. Works great

The purpose of Docker is to take an application and all of its needed dependencies and package them inside a container. This container is then run as a type of OS-level virtualization where each container is run separately, but still able to interact with other containers. Docker is very useful for app development, as it enables more efficiency, less overhead and faster deployment. Simply put, install Docker, and run your desired container. Through this guide, we’ll go through the process of how to get Docker installed on your Raspberry Pi.

Ensure We’re Up-To-Date

Raspberry Pi Install Docker Registry

To start, as always, it’s good practice to make sure the system is completely up-to-date before we begin or install any new software. This helps to ensure we’re not running or installing any outdated software and that the system has the latest information about what new software packages are available, if we happen to need any.

Tell the system to check for the newest available package versions and upgrade to them, while automatically confirming all user prompts.

To learn more about updating and upgrading Raspbian, including to the latest version of Raspbian, check out our post about how to Keep Raspbian Up-To-Date.

Download Docker

Raspberry Install Docker-compose

Docker already has an setup shell script ready to go from there official site. The script will determine what version you need, download and install it. We just need to download this script, like below.

Install Docker

Run the setup script.

Run As Non-Root User

By default, docker is meant to be run by the “root” user, and will kick back some permission warnings if you try and run docker commands with another user. We can fix that here by adding your default “pi” user to the “docker” group.

For permission changes to the “pi” user we need to Reboot.

Test Docker

The easiest way to test whether Docker has been installed and is in working order, it to run the “hello world” container.

If everything is good-to-go, you’ll see the “Hello from Docker!” message.

All done.