How to Install Docker on Your Raspberry Pi

How to Install Docker on Your Raspberry Pi

  • by Tyler (252)
  • Time to complete: 15 minutes

Docker is a tool that allows you to deploy applications inside of software containers. This can be useful for the Raspberry Pi because it allows users to run applications with very little overhead, as long as the application is packaged inside of a Docker image. You simply install Docker and run the container. This guide will walk you through the process of installing Docker on any version of Raspbian.

1

We can easily install docker using a shell script provided by (none other than) docker.

curl -sSL https://get.docker.com | sh

If you prefer to inspect scripts before executing them, you can split this command into two pieces:

curl -sSL get.docker.com -o get-docker.sh

# Make sure get-docker.sh looks right

sh get-docker.sh
2

If you try to run some docker commands, you'll notice a "permission denied" error, which indicates docker can only be run by the root user (using sudo). If you would like to run docker commands as your non-root user (default is pi), you can run the following:

sudo usermod -aG docker pi

The usermod command with -aG will append (-a) the user to the groups (-G). In the above case, we are adding the pi user to the docker group. This enabled pi to run docker commands. You can obviously substituted any user if you are not using the default pi user.

You can verify this with the following command:

groups pi

Ensure docker is listed as one of the groups.

3

To test docker, we'll run the hello-world image.

docker run hello-world

If Docker is installed properly, you'll see a "Hello from Docker!" message.