The purpose of this tutorial is to show how to install Docker on a Raspberry Pi system. Docker is a tool that is used to run software in a container. It’s a great way for developers and users to worry less about compatibility with an operating system and dependencies because the contained software should run identically on any system.
Docker is available for download and installation on Raspberry Pi and will run the same as it would on other Linux systems. After Docker is installed, you can use it to install software packages much the same way you would use your distro’s package manager to download an app. The difference of using Docker is that everything is more automated, with compatability and dependencies no longer being potential issues. In this tutorial, we’ll show you how to install Docker on a Raspberry Pi and get started with installing containerized software.
In this tutorial you will learn:
- How to install Docker on a Raspberry Pi
- How to run Docker without root
- How to search for a Docker image
- How to install a Docker image
- How to run a Docker image
- How to monitor Docker with various commands
|Requirements, Conventions or Software Version Used
|Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
How to Install Docker On Raspberry Pi step by step instructions
Follow the steps below to install Docker on your Raspberry Pi system.
- Get started by opening a terminal and typing the following two commands to update your package repository and to download Docker.
$ sudo apt update $ sudo apt install docker.io
- Once installation is completed, start the Docker service and, optionally, enable it to run whenever the Raspberry Pi is rebooted:
$ sudo systemctl start docker.service $ sudo systemctl enable docker.service
- You can verify that Docker is installed and gather some information about the current version by entering this command:
$ sudo docker version
- There is also a quick and easy way to see how many Docker containers are currently running and see some of Docker’s configured options by entering:
$ sudo docker info
Run Docker without root
- By default, you’ll have to use
sudocommand or login to root any time you want to run a Docker command on the Raspberry Pi. This next step is optional, but if you’d prefer the ability to run Docker as your current user, you can add your account to the docker group with this command:
$ sudo usermod -aG docker $USER
- You’ll need to reboot your system for those changes to take effect.
Searching for a Docker image
Now you are ready to install images with Docker. If you already know the name of an image that you would like to install, you can move on to the next section. If you need to search through Docker for the desired software, you can use the following command syntax:
$ sudo docker search [name]
For example, let’s try searching for
nginx, which is popular web server software.
$ sudo docker search nginx
As you can see, there is one official image for nginx (indicated by the
OFFICIAL column) simply called
nginx. There are also other releases available, and you would have to read their descriptions to see what they do differently from the official image.
Install a Docker image
Once you know which image you would like to install, you can use the following command to instruct Docker to download the desired software. Just as an example, we will install the
hello-world package which can be used to make sure that Docker is able to download and run images successfully.
$ sudo docker pull hello-world
The output in the screenshot above indicates that Docker was able to find and download the image we specified.
Running a Docker image
Once you have downloaded the
hello-world image, run it with the following command:
$ sudo docker run hello-world
How to Monitor Docker
Docker gives us a lot of options to see what’s going on with our images, how many system resources they’re using, etc. The following commands come in handy for monitoring Docker and our installed images.
- To see which Docker containers are running and check their current status, type:
$ sudo docker container ls
- To see a list of all the Docker images installed, type:
$ sudo docker images
- To see the current CPU, RAM, and network usage of running images, type:
$ sudo docker stats
- To see Docker’s network configuration, type:
$ sudo docker network ls
In this tutorial, we saw how to install Docker on a Raspberry Pi system. Docker is pretty easy to use on a Raspberry Pi. Like most new things, you just need to learn the command syntax that comes with it, which is very simple anyway.
Now that Docker is up and running on your Raspberry Pi, you’ll be able to search for and install new container images as you please. Chances are that you’ll find this a lot more convenient than manually installing or building certain packages on your own.