How to run Docker on Raspberry Pi

You no longer need to spend hours trying to compile and run a new software. Thanks to Docker, you can install pre-configured applications easily and ready to run.

You no longer need to spend hours trying to compile and run a new software. Thanks to Docker, you can install pre-configured applications easily and ready to run.

This is the perfect tool for software that often takes a long time to set up, such as web server or cloud backup tool. Combine it with the Raspberry Pi and you can set up your new IoT project after a few minutes.

Join TipsMake.com to find out how you can run Docker on the Raspberry Pi via the following article!

Install Docker

Before you install Docker, the article assumes you know how to set up a Raspberry Pi with Linux-based operating systems like Raspbian and you've done this.

For everyone, it is either running the latest version of Raspbian (Raspbian Buster) or if you are running another Linux distribution, open a terminal window and run the following command to start the installation:

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

Unfortunately, for those who are using Raspbian Buster, they may have trouble installing through the above script. If that is the case, then run the following command to use 'nightly' versions of Docker:

 curl -fsSL get.docker.com | CHANNEL=nightly sh 

However, please note that these versions may be unstable, so be cautious.

When you're done, and unless you're using the root user status (something you really shouldn't do!), Enter the following information so your user account has access to docker user groups. :

 sudo usermod -aG docker pi 

Change 'pi' to your own username, if you change from the default user.

Picture 1 of How to run Docker on Raspberry Pi

To check if Docker is installed correctly, enter the following command:

 sudo docker run hello-world 

This will download and run a very simple Docker container message 'hello world' in the terminal window. If you see a message like this, Docker is ready to use.

You can also run the sudo docker info command to see the complete list and details of your Docker configuration.

Find and install the Docker container

When Docker is set up, installing Docker containers is the next step you need to do. Containers are independent services that you want to run.

You can find many containers you need on Docker Hub, the official Docker repository for container applications.

Picture 2 of How to run Docker on Raspberry Pi

Some official software containers, like WordPress or PHP, are the official image of Docker. These images are certified by Docker, which means you can freely download and use them. Other images are provided by third parties, so be cautious if you plan on using these images for anything sensitive.

To install a container, locate the relevant package on the Docker Hub and follow any instructions provided. Use pull command to load containers. For example, if you want to download Apache to run your own Raspberry Pi web server, you need to enter:

 sudo docker pull httpd 

To download and run Apache directly, enter:

 sudo docker run -dit --name my-test-apache-app -p 8080:80 -v "$PWD":/usr/local/apache2/htdocs/ httpd:2.4 

This will then download the relevant files before running Apache using the default configuration. You can access it at http:/// your-pi-ip-address: 8080.

Picture 3 of How to run Docker on Raspberry Pi

If you are setting up a web server to use for production purposes, you may want to create your own Dockerfile (Docker configuration file) by following the Apache Docker Hub instructions.

Docker makes deploying IoT applications easy

If you plan to create your own containers, Docker may take some time for you to understand and accept. However, the use of built-in containers is quite easy, thanks to Docker Hub. Combine Docker with one (or some) Raspberry Pi as you can already use containers to quickly deploy new software. This is great for IoT, where you can own some devices that need the same software, with the same configuration.

There are many reasons why Docker and IoT always go together, so let people know what you intend to use Docker for. Do you want to run a web server or create a home automation system? Leave comments to share with everyone in the comment section below!

Hope you are succesful.

Update 28 July 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile