How to install docker on Raspberry Pi?

I recently came across a requirement where I needed to install docker on a raspberry pi and ran into an installation issue that I wanted to discuss so that it is easier for others who attempt this installation. You may have found many sources on the internet on how you can install docker on the raspberry pi. The steps are provided below. 

  1. You will need to upgrade to Raspbian OS version buster if you are running into issues as mentioned here.

  2. Update the repository package list using `sudo apt update`.

  3. Upgrade the distro using `sudo apt dist-upgrade -y`.

  4. Update the firmware using `sudo rpi-update`.

  5. Edit the sources to switch repositories that point to buster.

    1. sudo nano /etc/apt/sources.list

    2. Browse the file until you find: "deb http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi"

    3. Change this line by replacing stretch with buster: "deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi"

  6. Press Ctrl+X to save and exit, then remove a large changelog file: `sudo apt-get remove apt-listchanges`. This will save time when the operating system updates.

  7. With the sources updated you can run a full package update and upgrade: `sudo apt update; sudo apt dist-upgrade`.

  8. Clean up the package manager using `sudo apt autoremove -y`.

  9. Discard old packages with changed dependencies using: `sudo apt autoclean`.

  10. Reboot the pi using `sudo reboot`.

Once the Raspberry Pi is up, you can install docker using the following steps: 

  1. sudo apt-get update && sudo apt-get upgrade

  2. curl -fsSL https://get.docker.com -o get-docker.sh

  3. sudo sh get-docker.sh

  4. Add a non-root user to the docker group: sudo usermod -aG docker [user_name]

  5. Check docker verison: `docker version`.

  6. Check docker info: `docker info`.

  7. Run docker hello-world: `docker run hello-world`

Sources: 

Hope this helps! ☺️

Previous
Previous

How to use the rsync command?

Next
Next

How to manage your docker containers as a non-root user?