Install Docker On Raspberry Pi

To install Docker on Raspberry Pi 3, run the following command: $ sudo snap install docker. As you can see, Docker is being installed. It will take a while to complete. At this point Docker is installed. As you can see, the version of Docker is 18.06.1. It is Docker Community Edition. Sep 18, 2019 In my case this problem was solved by rebooting after installing updates, and before trying to install Docker. This will likely occur if you suddenly bring an older version of Raspbian up-to-date, and then straight away try to install Docker, as it appears some of the core binaries (or maybe even the kernel itself!) has been updated, the docker installer is reading those newer versions/files. Oct 09, 2020 To install the latest version of Docker on Raspberry Pi and to be able to upgrade it easily in future – it is recommended to install Docker from the official repository. In this guide i will show how to install free Docker CE (Community Edition) on Raspberry Pi (Raspbian) from the stable official repository, how to verify that it has.

Step 5: Install Docker on Raspberry Pi. In this step we’ll finally be getting to the fun stuff, installing the Docker Engine. Update your system again now that we have added a new repository! Sudo apt update sudo apt-get install docker-ce docker-ce-cli containerd.io. 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.

Docker? Docker is a software platform that levels the playing field. It creates an autonomous environment for running applications that is completely removed from hardware, operating system, and other software. It removes the guesswork from installing and running applications, because it removes all the variables from the environment. Once you have created your docker environment, you can run anything that’s been containerized for docker. Caveat emptor: we’re doing this on Raspberries so we’ll have to look a little deeper to find containers that have been created on the armhf architecture if we want them to run. So, let’s get docker installed on a couple of Raspberries and then create a little cluster to get them to share resources and create everyone’s favorite platform.

Basic Docker Install

On each of the Raspberries that you’d like to be your docker cluster run the following. We’re going to download a script from docker.com and run it to do an automated install.

Add the pi user to the docker group. This gives pi all the rights and privileges required to run docker without having to rely on the root user.

AND you’re done. Good job. End of post. Yeah, but you were hoping for a little more. Reboot and login as pi, then try to use this command to download and run an Ubuntu container. If all goes well, you’ll get an Ubuntu shell prompt.

YAY! It works. Now, let’s set docker to load at start up:

Create the swarm

OK! We’ve got docker running on our Pis! Next, we need to put them in contact with each other so they can share resources and spread the load. The mechanism to do this is called “swarm”. Basically, what we’re doing is creating a cluster of raspberries. The process is to install swarm on the main node, the manager, and then join the other raspberries running docker to the manager. You’ll need the IP address of your manager for this command. I’m calling my manager docker0. Its address is 192.168.1.20.

The command initializes the swarm, sets up the node as manager, and then spits out the command to run on the rest of the nodes. I’ll just cut&paste that command into the other nodes’ terminals. Then I can check my work with the command:

Skimming through the info presented, I find:

… which is what I was expecting. Another way to confirm this is to run:

Install a Container

Let’s run a container! Keep in mind that we need to look for containers that have been created to run on ARM architecture! I knew about viz and was happy to find that someone had ported it to armhf. Since we’re already trying to visualize our new swarm, let’s run an image provided by @alexellisuk. Cut and paste this into your manager node:

This command will download, configure, and run your first container. The publish line is the argument that tells docker what port to expose to the network. Fire up your browser, surf to the IP address of your manager:8080:

Docker

We can see a graphical representation of our swarm! We see the “viz” container in the running state. AND, good news, I finally found my 8GB raspberry! It’s running as docker2!

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.

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

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.

Install

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)

Install Docker On Raspberry Pi 2

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.

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

Install Docker On Raspberry Pi Zero W

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