How to Install Docker on a Raspberry Pi

Brandon Cannaday
Brandon Cannaday | 2 minute read

Docker is an increasingly important component used to distribute software, especially for complex use cases like Edge Computing and IoT. The Losant Edge Agent, for example, is distributed as a Docker container. We've found the Raspberry Pi to be a popular choice for enterprise users who are in early development or the proof-of-concept phase of their IoT projects.

In order to use Docker on a Raspberry Pi, it must first be installed. This tutorial provides step-by-step instructions for installing and testing Docker on your Raspberry Pi.

Install Raspbian

This tutorial assumes that your Raspberry Pi is running Raspbian. It's likely that these instructions will work on other Linux distributions, but there are no guarantees.

Download and Execute the Docker Installation Script

Run the following command to download the Docker installation script:

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

This script is provided by Docker and takes care of installing all necessary dependencies and the Docker runtime itself. Check out the curl man page for more information about that command. Once the script has successfully been downloaded, execute it using the following command:

sh get-docker.sh

Allow Non-Root Users to Execute Docker Commands

By default, only root users are able to access Docker. For other users to execute Docker commands, they must be members of the "docker" group, which was created by the installation script. Add your current user to the "docker" group by running the following command:

sudo usermod -aG docker $USER

Check out the usermod man page for more details about that command. The $USER environment variable holds the name of the current user, for example, "pi."

Testing Docker on a Raspberry Pi

To make it easy to test your installation, Docker provides a hello-world container that can be run using the following command:

docker run hello-world

If successful, the container will print the following information and then exit:

Docker hello-world Output

IoT Enable Your Raspberry Pi

With Docker installed, you can now install the Losant Edge Agent, which brings powerful Edge Compute functionality to your Linux gateways. The Losant Edge Agent makes it easy to read data from local controllers and sensors and securely transmit that data to the Losant Enterprise IoT Platform.

Industrial Equipment Monitor IoT Application

If you'd like to learn more about using a Raspberry Pi with Losant, check out these other tutorials:

Losant provides a full-featured and no-cost Developer Sandbox where you can begin exploring the platform for yourself. If you'd like to learn more about Losant or talk to one of our team members, please contact us!

Tagged