Use the following code to install Docker on Raspberry Pi. I have tested that it works on Raspberry Pi 3 B+. This code is taken almost verbatim from withblue.ink/2019/07/13/yes-you-can-run-docker-on-raspbian.html.
# Install some required packages first
sudo apt update
sudo apt update
sudo apt install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
# Get the Docker signing key for packages
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -
# Add the Docker official repos
echo "deb [arch=armhf] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
$(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list
# Install Docker
sudo apt update
sudo apt install -y \
docker-ce \
cgroupfs-mount
To start Docker:
sudo systemctl enable docker
sudo systemctl start docker
To pull a lightweight OS for Docker running on Raspberry Pi 3 B+ try Alpine Linux:
sudo docker pull arm32v7/alpine
After executing the command get the image ID to continue:
sudo docker images
[email protected]:~ $ sudo docker images REPOSITORY TAG IMAGE ID CREATED SIZE arm32v7/alpine latest 3e8172af00ce 5 weeks ago 3.82MB
Get inside by issuing the following command. Notice that you are at another prompt now. To confirm that you are inside your container try “ls” to get a directory listing and you should notice you are indeed in Alpine now. Use “exit” to get back to your Raspberry Pi prompt.
sudo docker run -it 3e8172af00ce sh
[email protected]:~ $ sudo docker run -it 3e8172af00ce sh / # ls bin dev etc home lib media mnt opt proc root run sbin srv sys tmp usr var / # exit [email protected]:~ $