Installing Docker on Raspbian for the Raspberry Pi

Last Friday I wrote a post how to install Docker on ARM64 devices. Today I will describe how to install Docker on Raspbian (Stretch).


The hardware choice is very obviously the Raspberry Pi, and to be more exact it’s the brand new Raspberry Pi 3 Model B+. This Raspberry Pi model has the following specs;

  • Broadcom BCM2837B0, Cortex-A53 (ARMv8) 64-bit SoC (1.4GHz)
  • 2.4GHz and 5GHz IEEE 802.11.b/g/n/ac wireless LAN, Bluetooth 4.2, BLE
  • Gigabit Ethernet over USB 2.0 (however the maximum throughput is around ~300 Mb/ps)
  • 5V/2.5A DC power input (however it can run on 2A power adapter just fine)

Operating System

For the Operating System I’m going for Raspbian Strecth Lite.
although the processor that comes with the Raspberry Pi 3B+ is a 64 bit’s CPU, Raspbian is not 64 bits. At this moment all Raspbian versions are 32 bits only  😥

Installing Docker

Let’s get started but first let’s confirm that the processor is a ARMv8. Let’s run the uname command to verify this;

$ uname -m

Euh, this can’t be right? … the uname command shows us that the processor is a ARMv7 where it should be an ARMv8.

Unfortunately this is because Raspbian is still running with the same 32-bit kernel as the 2B that have a ARMv7 processor. So it will report that it have a ARMv7 when your using a 32-bit kernel.

So the hardware side is a ARMv8 but on the software side it will be shown as a 32 bits ARMv7.

Just like the previous post on how to install Docker on Armbian, we could use the Docker supplied repositories. This is because Rasbpian is just like Armbian so it’s based on Debian, and Docker will provide installation sources for Debian based systems.

Pre-installation steps

The first task is to install the required packages and configure the Docker repository.
Lets start with installing the packages.

$ sudo apt install -y \
       apt-transport-https \
       ca-certificates \
       curl \
       gnupg \

Once the packages have been installed the next step is to add the Docker GPG key.

$ curl -fsSL | sudo apt-key add -

The next step is to add the Docker repository.

$ echo "deb [arch=armhf] \
       $(lsb_release -cs) stable" | \
       sudo tee /etc/apt/sources.list.d/docker.list

Docker installation

Tell the system there is a new repository available we need run a update command

$ sudo apt update

When running the update command you should see there are two Docker repositories added to the repo list.

NOTE: it’s only required to run a update and not the upgrade command 😉

Once all the previous commands have been run successfully, it’s time to install Docker!

$ sudo apt install -y docker-ce

Great Docker has been installed, now the final step is to check if it’s running asARMv7.

$ docker version

This should show you an output that consist of two parts; one is the Docker Client and one is the Docker Engine, both should show ARMv7 at the OS/Arch section.

$ docker version
 Version: 18.03.0-ce
 API version: 1.37
 Go version: go1.9.4
 Git commit: 0520e24
 Built: Wed Mar 21 23:18:37 2018
 OS/Arch: linux/arm
 Experimental: false
 Orchestrator: swarm

  Version: 18.03.0-ce
  API version: 1.37 (minimum version 1.12)
  Go version: go1.9.4
  Git commit: 0520e24
  Built: Wed Mar 21 23:14:43 2018
  OS/Arch: linux/arm
  Experimental: false

If you see any error’s on the server side, than perhaps you need to add your account to the docker group;

$ sudo addgroup [your account] docker

Great everything is installed and running with ARMv7 support.
Lets try to start a Alpine container.

$ docker run -it alpine sh
$ exit

And run the command to check what CPU architecture it’s running.

$ docker run -it alpine uname -a
Linux dc6ec2b6a1a3 4.14.30-v7+ #1102 SMP Mon Mar 26 16:45:49 BST 2018 armv7l Linux

As you can see the container is running as ARMv7, so we have successfully running Docker on our Raspberry Pi!

NOTE: when using Docker on ARM CPU architectures you need a ARM based container image, otherwise you get EXEC errors because the base image has been build on a AMD/Intel machine.

However more and more images will have support for multiple architectures so you can run it on your desktop pc running Intel or AMD processors and your little Raspberry Pi.

That’s it.. happy Dockering!

1 Comment

Mike · September 1, 2018 at 5:27 pm

thanks a lot!

Leave a Reply

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