!!! Docker image on compatible with Raspberry pi4 must be ARM64 in the Docker hub site (check on left side the parameters arm64)
Opposed to most other Linux distributions, Raspberry Pi is based on ARM architecture. Hence, not all Docker images will work on your Raspberry Pi.
In fact, all Docker images that are not specifically designed for ARM devices will not work. Running docker-apps designed for x86/x64 and i386 architecture on your Raspberry Pi will return an error.
$ sudo apt-get update && sudo apt-get upgrade
$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh
$ sudo usermod -aG docker Pi
// Verify ok
$ docker info
// Run a first app:
$ docker run hello-world
// Run on the pi CLI
$ docker run -d -p 80:80 hypriot/rpi-busybox-httpd
// To upgrade Docker on Raspberry
$ sudo apt-get upgrade
Install docker compose on pi
$ sudo pip3 install docker-compose
// test it
$ docker-compose --version
Setup Docker on Linux
Docker was made to run on Linux native (unbuntu)
// See if docker is installed
$ docker --version
// if old version of docker, deinstall it
$ sudo apt-get remove docker docker-engine docker.io containerd runc
// Update the apt package index and install packages to allow apt to use a repository over HTTPS:
$ sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
// Add Docker’s official GPG key:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
// Verify that you now have the key with the fingerprint ending with 8 caract
$ sudo apt-key fingerprint 0EBFCD88
// set up the stable repository
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
// Update the apt package index, and install the latest version of Docker Engine and containerd
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
// Verify that Docker Engine is installed correctly by running the hello-world image.
$ sudo docker run hello-world
!! Docker-machine and docker-compose are not installed by default with the command here above (which is the case with MAC, so you will need to install them manually
// To launch a docker image and interact with it on terminal
$ docker run -ti alpine /bin/sh
// - t for interacting with image in terminal and -i for interactive session
// /bin/sh is beacause bash was not present on alpine initially but can work now without it
//StartanewcontaineronterminalCLI$dockercontainerrun--publish80:80nginx//thengotobrowserandenter:localhostyoushouldseepageifsetupsucceed//publishoptionmeans:youcanspecifyaftertheportmappingPC ->Dockercontainerinternalprocess//tokillitCTRL+C//Startanewcontainerondetachedmodeinthebackground$dockercontainerrun--publish80:80--detachnginx//wegetbacktheuniqueidofrunningcontainer:7886d73b04a7d45bf637cd3ab70c85ff6a7eaf53bf38060d8e5bda7148a1ae61//Listourcontainer$dockercontainerls//Stopthecontainer//dockercontainerstop"a few first Digit of the id is ennough"$dockercontainerstop788$dockercontainerls-a//wehavethelistofallcontainerthathavebeencreated//thenamefieldisautogeneratedbydockerifnotspecifiedbyus//namescomefromalistofknownhackerofscientist,sothisisafunnypart//Startacontainerwithaspecifiedname$dockercontainerrun--publish80:80--detach--nameHelooNamenginx//Toseethelogofthedetachcontainerrunning$dockercontainerlogsHelooName//fulldump//Displaytheprocessesrunninginsideacontainer$dockercontainertopHelooName//Helpcommand$dockercontainer--help//Stopandremovecontainer$dockercontainerrm-f"list of containerIDFirstLetters separated by space"$dockercontainerls-a (to verifywedon't have any container anymore)