How to install Docker on Raspberry Pi

How to install Docker on Raspberry Pi

Because the Raspberry Pi is based on ARM architecture, the installation and use of Docker are also different. There is a lot of content that needs to be discussed, so I will just pick it out here.

Raspberry Pi is based on ARM architecture, which is different from PC. So even if you can make some docker images on the Raspberry Pi, you can't run them on other PCs. Conversely, Docker images on other PCs cannot run on the Raspberry Pi.

If you need to find a Raspberry Pi-specific image, just search for ARM or Rpi on Dockerhub .

There is a warehouse called Hypriot that has made a lot of dockers specifically for Raspberry Pi, you can refer to it.

Raspberry Pi reference: Get Docker CE for Debian

Reference: My home server powered by Pi and Docker

The most difficult part of installing Docker on Raspberry Pi is to correctly select the source and add the GPG-key, so that you can find and download the appropriate version of Docker. This process is very cumbersome and it is difficult to have a unified solution.

Official version one-click installation script

Note: Many people say that the official one-click installation script is no longer supported. But the current position is actually still supportable.

Reference: The easy way to set up Docker on a Raspberry Pi

Before I start, let me explain: I have failed many times before and have found many related solutions but none of them worked. until. . .

It didn't work until I sudo apt-get update and most importantly sudo apt-get upgrade .

In fact, you can see during the upgrade that many system dependency packages have been updated, which solves all the problems that caused the previous unsuccessful Docker installation.

After the upgrade is completed, the formal installation begins:

You need to use a shell script, get.docker.com , and the entire website has only this one script. Download and execute:

$ curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh

When completed, it will display:

Then run hello world and try it out:

$ sudo docker run hello-world

Then it displays:

Manual Installation

Preparation:

#Install SSL related, let apt download via HTTPS:
sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common

# Add docker's GPG key
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
# Check if the key matches (9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88)
sudo apt-key fingerprint 0EBFCD88

#Add apt download source for docker sudo echo "\ndeb-src [arch=amd64] https://download.docker.com/linux/debian wheezy stable\n" >> /etc/apt/sources.list

#Update source sudo apt-get update

Install docker:

$ sudo apt-get install docker-ce

Execute docker without sudo

In order to avoid having to type sudo every time you execute docker , we need to create a user group for docker and grant permissions:

# Create the docker user group sudo groupadd docker

# Add the current user to the docker user group sudo gpasswd -a $USER docker

# Update the current user group changes (no need to log out and log in again)
newgrp docker

Install docker-compose

You can download and run docker compose as a docker container:

docker run \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v "$PWD:/rootfs/$PWD" \
  -w="/rootfs/$PWD" \
  docker/compose:1.13.0 up

# Set alias shortcuts (`~/.zshrc` or `~/.bash_profile`)
alias docker-compose="'"'docker run \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v "$PWD:/rootfs/$PWD" \
  -w="/rootfs/$PWD" \
  docker/compose:1.13.0'"'"

Common Errors

Python: No module name lsb_release

First check whether lsb_release is already installed on your machine, or reinstall it:

$ sudo apt-get install lsb-release

If you still have this problem, check your Python version. If it is python3, then it is likely that the version is insufficient, because lsb_release requires at least python3.5.
To solve this problem, just set the default python back to python2. It's just a matter of creating a shortcut with ln:

# Backup (the specific location of Python depends on your own situation)
$ sudo mv /usr/bin/python /usr/bin/python_bak

# Replace $ sudo ln -s /usr/bin/python2.7 /usr/bin/python

Then try $ lsb_release -cs again to see if jessie is displayed

無法添加源add-apt-repository 報錯找不到相關源

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Installation steps of docker-ce on Raspberry Pi 4b ubuntu19 server
  • How to install Docker and configure Alibaba Cloud Image Accelerator
  • How to view files in Docker image
  • How to use Docker buildx to build multi-platform images and push them to private repositories
  • Use the docker build kit to build a Docker image that can be used on the Raspberry Pi

<<:  React ref usage examples

>>:  MySQL 4G memory server configuration optimization

Recommend

How to use gdb to debug core files in Linux

1.core file When a Segmentation fault (core dumpe...

Solutions to MySql crash and service failure to start

I have been in contact with PHP for so long, but ...

Detailed installation tutorial of mysql 5.7 under CentOS 6 and 7

You always need data for development. As a server...

Example code of vue custom component to implement v-model two-way binding data

In the project, you will encounter custom public ...

Sample code for CSS image animation effects (photo frame)

This article introduces the sample code of CSS pi...

MySQL 5.6.22 installation and configuration method graphic tutorial

This tutorial shares the specific code of MySQL5....

Introduction to the use of MySQL performance stress benchmark tool sysbench

Table of contents 1. Introduction to sysbench #Pr...

Detailed explanation of MySQL 8's new feature ROLE

What problems does MySQL ROLE solve? If you are a...

js realizes a gradually increasing digital animation

Table of contents background Achieve a similar ef...

JavaScript css3 to implement simple video barrage function

This article attempts to write a demo to simulate...

jQuery plugin to achieve image comparison

This article example shares the specific code of ...

Detailed explanation of CSS3 flex box automatic filling writing

This article mainly introduces the detailed expla...