Running software in a container, instead of directly on a computer/server has many benefits, as you likely know, since you’re reading this. But for me, one of the key things is the separation. I like to keep my systems issolated, to avoid issues which might ordinarily result in a full system re-install. Of course, there are many other benefits too, such as increased speed of deployment, running duplicate systems, on one machines, mobility, scaling etc.
If you’re not familiar with Docker and/or containerisation, please research it before proceeding, or accept that things may go wrong for you, if you’re learning.
Let’s get started.
Make sure your Raspberry Pi is up to date
Open a terminal window on your Raspberry Pi, and run the two commands below, to update your system:
sudo apt-get update
sudo apt-get upgrade
It could take some time, especially if it’s a new setup, so please be patient.
Reboot your pi by using the below command:
sudo reboot
Install Docker on your Raspberry Pi
First, we need to download the Docker installation script, from our friends at Docker, by opening a terminal window and running the below:
curl -fsSL https://get.docker.com -o docker-script.sh
Now we need to execute the downloaded script by running the below:
sudo sh docker-script.sh
If you see the below error, run this command:
sudo dpkg --configure -a
Add a user to the Docker group
Presuming your username is the default ‘pi’, run the below command. If your username is anything different, change ‘pi’ to the username you want in the group:
sudo usermod -aG docker pi
Check Docker is installed ok
It’s worth checking that Docker is installed, and that you have correctly assigned the users to the Docker group. To do this, run the below command:
docker info
If every thing is working as expected, you should see something like the below:
If you see a permission denied error, ensure you have added the correct user/s to the Docker group, and if you are sure you have, make sure you reboot your system, and run the command again.
Check your version of Docker
If you need to check what version of Docker you have installed and running, just use the below command:
docker version