Skip to main content
Installing Docker & Docker Compose on Raspberry Pi

Installing Docker & Docker Compose on Raspberry Pi

·369 words·2 mins
Neelakantan C A
Author
Neelakantan C A
Table of Contents

What is Docker & Docker Compose ?
#

Docker is method to easily deploy and maintain applications in containers.

Containers are isolated prepackaged environments that include all dependancies required to run a certain piece or set of software. This makes it easy for developers to ship and deploy their software without having to worry about the environment or dependancy issues on the end users machine

Docker compose, essentially is one file that specifies how multiple docker containers are laid out in a network as well as the configuration of each individual container. Using a docker-compose.yml file, multiple services can be run with one command.

Why install Docker ?
#

Docker can be used to run a variety of services like:

  • a full web stack
  • running a small game server

In later posts, we will look into using docker on a Raspberry Pi to block ads on a network scale rather than use adblock on every machine.

Installation Steps
#

Docker
#

The following guide has been written and tested on a Raspberry Pi 3B+

Before we install anything, we need to first ensure the Pi is updated.

sudo apt update && sudo apt upgrade

Now that the Pi is upgraded with the latest software.

curl -sSL https://get.docker.com -o ./docker-install.sh

Take a moment to review the contents of the install file looking for any suspicious lines of code. After you’re satisfied go ahead and run the next command.

sudo sh ./docker-install.sh

Let the installation finish, now before we can run use docker, we must give our current user the permissions to use docker. We first find our username by running the id command, then adding our user to the docker group.

$ id
uid=1000(reith)....

$ sudo usermod -aG docker reith

Now we can test docker by running the following command:

docker run hello-world

If there are no errors, and docker outputs a “hello world” message, docker has been installed successfully and we can get rid of docker-install.sh if we’d like.

Docker Compose
#

To install docker compose we first need to install python3.

sudo apt install python3 python3-pip

Now we can install docker-compose by running the command:

sudo pip3 install docker-compose

To test if docker-compose is installed, run docker-compose -v