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.
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:
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:
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.
If you'd like to learn more about using a Raspberry Pi with Losant, check out these other tutorials:
- How to Access the Raspberry Pi Camera in Docker
- How to Access the Raspberry Pi Camera from the Losant Edge Agent
- Analyzing IoT Image Data using Losant and the Google Vision API
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!