Docker containers are the new trend in deploying micro services without the need of duplicating Os job on host machine. They are also fast and allow quick development techiques unavailable in classic development. It is possible (and useful) install Docker in Raspberry PI reckoner boards, getting container advantages in our powerful single lath, credit sized computer

In this tutorial, I’ll show you how to set up a docker environs and Portainer (a powerful docker GUI) with Raspberry PI Bone Lite.

With the new Raspberry PI OS, it’s interesting to check if some basilar installations are going to be as simple equally with the previous version.

Ane of my favourite RPI features was using containers to deploy in very simple means services similar Nginx, python, Linux distributions, spider web servers, IoT applications and then on.

With the open source docker engine, you can use docker containers to get with the single line “docker run” commands. Y’all can as well use base images to customize your services with the “docker build” control and very simple dockerfiles. The docker-etch command enables you to deploy complete services defined in elementary “docker-compose.yml” files. Finally, the “docker swarm” command will simplify Raspberry PI cluster creation to distribute the load between unlike physical boards.

When using Docker Hub images for your projects, you need to check that these are available for ARM compages: Raspberry PI has arm processors, then only those docker images which are compiled for arm tin be run on RPI. Sometimes besides processor version can be crucial: for example, some docker images are compiled to run only with armv7 or newer.

Popular:   Home Server Setup - Turn your old PC into a useful home server

This procedure has been tested on a Raspberry Pi model Aught Westward, PI 3 Model A+, PI 3 Model B/B+, PI four, but the same steps should work for all other Raspberry Pi models with internet connectivity.

What we need

To setup our docker environment using the new Raspberry Pi model A+, we’ll not use keyboards or TV cables. Our OS installation will provide a basis having already WiFi and SSH set to be used at beginning kicking.


SANDISK Ultra 16GB MicroSD

I suggest adding from now to your shopping chart all needed hardware so that at the terminate you will be able to evaluate overall costs and decide if continue with the projection or remove them from the shopping cart.

  • Raspberry PI 3 Model A+ (including proper power supply or using a smartphone micro usb charger with at least 3A) or newer Raspberry PI Estimator Lath
  • high speed micro SD card (at least 16 GB, at least grade 10)

Check hardware prices with the following links:

Amazon raspberry pi boards box

Amazon Micro SD box

Amazon Raspberry PI Power Supply box

Stride-by-stride guide to setup Docker

Setup process is really uncomplicated.

Set up Operating Arrangement

The first footstep consists of installing Raspberry PI Os Lite, to go a fast and light operating system

Before going on docker engine installation, be certain to take an updated OS. From SSH command line, blazon the following commands:

        sudo apt update -y && sudo apt upgrade -y

Install Docker on Raspberry PI

The default (and suggested) docker engine installation comes with a convenience script, a simplified bash installation script that makes all the piece of work for you lot. This adds repositories to your apt file, download and installs dependencies and the latest Docker engine version. Type post-obit commands from the final:

        roll -fsSL -o sudo sh

It volition take a few minutes to complete the installation.

Popular:   Difference Between Tampax Radiant and Tampax Pearl

Some Raspberry PI models experienced an “Eastward: Sub-procedure /usr/bin/dpkg returned an error code (1)” after “sudo sh” command. Ashley, in this post comments, found that calculation “cgroup_enable=memory cgroup_memory=1 swapaccount=1” in /boot/cmdline.txt solved this error in Raspberry PI 4 Model B. This modify requires a reboot.

At prompt, test it by typing the following docker command:

        sudo docker version

From here, your “docker run” commands are available to deploy your favourite docker containers.

You can likewise test by running the default hullo-world docker paradigm past docker run command:

        sudo docker run hello-world

Since this is your very first container deployed and y’all haven’t any related paradigm already downloaded, information technology volition download the requested docker container from Docker Hub, excerpt packages and run them.

If you would like to use Docker equally a non-root user, you should now consider adding your user to the “docker” group. To accomplish information technology for default pi user:

        sudo usermod -aG docker pi

Y’all volition need to logout and login (or reboot) to make it work or you will accept still permission issues using docker without sudo.

Install Portainer

A graceful spider web GUI helping in managing containers is portainer. In our case, nosotros need to install an arm compatible version and and so launch it with the docker run command:

        docker pull portainer/portainer:linux-arm docker run -d -p 9000:9000 -five /var/run/docker.sock:/var/run/docker.sock -five portainer_data:/data portainer/portainer:linux-arm

Now you can reach your docker server with a browser, just connecting to https://<<RaspberryIpAddress>>:9000.

You lot will be required to set your default countersign for the admin user, and then you will be prompted to portainer GUI:

Popular:   Differences Between Worm and Caterpillar
Portainer new

Install Docker-compose

Docker-compose enables your Docker environment to employ yaml files to compose and quickly boot complete services. Its official folio suggests installation with pip3, only this sometimes results in non working. So, I advise using the more resilient apt installation using default repositories, with the following control from the last:

        sudo apt install docker-compose

Verify your docker-compose installation by typing:

        docker-compose --version

Enjoy your Docker environment inside the Raspberry PI!