How to install Docker to Raspberry Pi?

Installation

Step1

Update all our existing packages before we proceed to install Docker.

We can upgrade all existing packages by running the following two commands on the Raspberry Pi.

sudo apt update

sudo apt upgrade

Step2

After this install Docker. We will use official Docker setup script to install Docker. Follow the following command for the same.

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

This script can take some time to complete as it automatically detects and installs everything it needs to run Docker on the Raspberry Pi.

Alternatively, you can download the script from get.docker.com and review and run.

Setting up Docker

In order to be able to interact with Docker, the user needs to be added to the docker group. By default, only the Docker user can interact with Docker.

To add our current user to the docker group use the usermod command as shown below.

sudo usermod -aG docker $USER

By using “$USER” we are inserting the environment variable that stores the current users name.

If we don’t add our user to the group, we won’t be able to interact with Docker without running as the root user.

Once you have logged back in, you can verify that the docker group has been successfully added to your user by running the following command.

To make sure that the user addition is reflected, logout and login back.

groups

This command will list out all the groups that the current user is a part of. If everything worked as it should, the group docker should be listed here

Testing the Docker Installation on Raspberry Pi

To test if Docker is working, we are going to go ahead and run the following command on our Pi.

This command will tell Docker to download, setup and run a docker container called “hello-world.

docker run hello-world

If you have successfully installed Docker to your Raspberry Pi, you should see a message with the following text in it.

Hello from Docker!

This message shows that your installation appears to be working correctly.

Conclusion

With Docker now set up on your Raspberry Pi, you’re ready to explore its full potential—whether it’s running lightweight containers or building a full-fledged Docker Swarm. It’s a powerful tool that simplifies deploying and managing software on your device.

In the next post, we’ll take this further by using Docker to install the Homepage Dashboard, a clean and customizable interface to organize and access your self-hosted applications with ease. Stay tuned!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.