Install Docker on Raspberry Pi

This guide will cover the basic setup and installation of docker and docker-compose on a raspberry pi. This guide is a prequel to many other guides found on this site.

  • Any RaspberryPi (3 or 3B+ Recommended)
  • MicroSD 16GB+
  • USB Keyboard
  • Network cable or Wifi to connect to your home network
Setup the microSD Card

To run docker on your raspberry pi, we need to install the main filesystem on our microSD card which the pi can boot from. Since we will only use the terminal, there’s no need for installing a desktop environment so download the Raspbian Jessie Light image on their website.

To flash an image onto an sd card, you can use one of the following depending on your current platform

Insert the MicroSD in your pc using a USB card reader or a built-in reader, then open the software for your platform, select the image file and click Flash/Write (you should extract the downloaded zip/7z/gz to get the actual .img file)

When the writing is done, plug in a USB keyboard and screen into your raspberry pi, insert the sd card and power on your pi. If using a network cable connect it now. Wifi will be set-up later.

Setup Network

I recommend using a wired ethernet connection to your raspberry pi, this minimizes the risk of random disconnects due to losing wifi connectivity. I also highly recommend using a static IP for your raspberry, this can be done in your router by assigning a static IP to your raspberry pi’s mac address. Then, to remotely access the pi, I will enable ssh so the USB keyboard and screen are not needed anymore.

Ethernet cable

Simply connect an ethernet cable to your raspberry pi’s ethernet port, no other steps necessary as long as your router’s DHCP provides an IP. When starting the pi with the network cable attached, the console should print it’s IP when it was able to obtain one.


To enable wifi, you will need to set your country first. This can be done by typing


A gray menu should open. Navigate to “Localization Options” and follow the screenshots below to select your country using the arrow and enter key:

Then to enable wifi, follow these screenshots but provide your access point information

Enter your passphraze and your raspberry pi should connect to your wifi.

Enable SSH

Static IP in the router

Setting a static IP in your router is different for each brand and/or model, I’ve got a Netgear R8000. The static IP settings are located under: General Settings -> Lan Settings -> Static Route. You usually have to provide a name, IP and mac address to add the static route to your DHCP. This entry will make sure your raspberry pi always gets the same pre-assigned IP from your router.

Click apply in your router (this will in some cases reboot your router). Then reboot your raspberry pi using “sudo reboot now”. The IP should now be updated to the one set in your router. If not you should be aware that the wifi and ethernet port have different mac addresses. So when you switch from wifi to a wired connection, the raspberry pi won’t match the entered mac address

Install Docker

Once ssh is enabled and your network is connected. You can remotely set up your raspberry pi using Terminal(mac) or putty(windows). To connect simply run “ssh [email protected](RASPBERRYPI’S IP)” then fill in the password (raspbian by default). you can also continue using the USB keyboard, the steps remain the same.

Before installing docker, we want to make sure our raspberry pi software is up to date, this can be done by running following commands

sudo apt - get update
sudo apt - get -y dist-upgrade

This may take a while. After it is done, we can start installing Docker. First, add docker’s official GDG-Key

curl -fsSL | sudo apt-key add -

Then use the following command to add/choose the stable branch from the docker repository

echo "deb [arch=armhf] stretch stable" | sudo tee /etc/apt/sources.list.d/docker.list

Update sources “apt-get sources” by typing following command

sudo apt-get update

Then for the actual installation

sudo apt-get install docker-ce

Then for the last step, add the docker user, this will stop your ssh session. reconnect when the command is executed

sudo usermod -aG docker pi && logout

To add docker compose, run following command (this will take a while depending on your pi)

sudo apt-get -y install python-setuptools && sudo easy_install pip  && sudo pip install docker-compose

To verify docker and docker-compose are installed and working, type docker or docker-compose –version

If both packages print their version correctly, your docker setup is completed.



5 Responses

  1. After running

    sudo apt-get -y install python-setuptools && sudo easy_install pip && sudo pip install docker-compose

    i get an error
    Command “python egg_info” failed with error code 1 in /tmp/pip-build-4ercnm/pynacl/

    whats going wrong

    grts. Rob de Wilde

  2. Hi after running sudo pip install docker compose, i am getting an error.

    ERROR: Command “/usr/bin/python /usr/local/lib/python2.7/dist-packages/pip-19.1.1-py2.7.egg/pip install –ignore-installed –no-user –prefix /tmp/pip-build-env-B3vIZv/overlay –no-warn-script-location –no-binary :none: –only-binary :none: -i — setuptools wheel ‘cffi>=1.4.1; python_implementation != ‘”‘”‘PyPy'”‘””” failed with error code 1 in None

    I used these instructions to install docker ( instead of yours i thought that wouldn’t make a difference.
    I am also using Stretch not Jessie.

    The python 2.7 seems suspicious especially as there is a deprecation notice.
    I have tried using python 3 but no joy there either.

    Am i missing something obvious or have things changed a lot in the past 5 months?

    Thanks R

Leave a Reply

Your email address will not be published.

On Key

Related Posts

%d bloggers like this: