mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-03-07 15:59:26 +00:00
Fix and update
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
## 树莓派卡片电脑安装 Docker
|
||||
|
||||
## 树莓派卡片电脑安装 Docker
|
||||
|
||||
树莓派等 ARM 架构设备在物联网和边缘计算领域应用广泛。本节介绍如何在树莓派上安装 Docker。
|
||||
|
||||
>警告:切勿在没有配置 Docker APT 源的情况下直接使用 apt 命令安装 Docker.
|
||||
|
||||
### 系统要求
|
||||
|
||||
Docker 对 ARM 架构有着良好的支持。
|
||||
|
||||
Docker 不仅支持 `x86_64` 架构的计算机,同时也支持 `ARM` 架构的计算机,本小节内容以树莓派单片电脑为例讲解 `ARM` 架构安装 Docker。
|
||||
|
||||
Docker 支持以下版本的 [Raspberry Pi OS](https://www.raspberrypi.org/software/operating-systems/) 操作系统:
|
||||
@@ -16,6 +22,8 @@ Docker 支持以下版本的 [Raspberry Pi OS](https://www.raspberrypi.org/softw
|
||||
|
||||
### 使用 APT 安装
|
||||
|
||||
推荐使用 APT 包管理器进行安装,以确保版本的稳定性和安全性。
|
||||
|
||||
由于 apt 源使用 HTTPS 以确保软件下载过程中不被篡改。因此,我们首先需要添加使用 HTTPS 传输的软件包以及 CA 证书。
|
||||
|
||||
```bash
|
||||
@@ -39,7 +47,10 @@ $ curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/raspbian/gpg | sudo apt-
|
||||
|
||||
|
||||
## 官方源
|
||||
|
||||
## $ curl -fsSL https://download.docker.com/linux/raspbian/gpg | sudo apt-key add -
|
||||
|
||||
|
||||
```
|
||||
|
||||
然后,我们需要向 `sources.list` 中添加 Docker 软件源:
|
||||
@@ -52,15 +63,21 @@ $ sudo add-apt-repository \
|
||||
|
||||
|
||||
## 官方源
|
||||
|
||||
## $ sudo add-apt-repository \
|
||||
|
||||
## "deb [arch=armhf] https://download.docker.com/linux/raspbian \
|
||||
## $(lsb_release -cs) \
|
||||
|
||||
## $(lsb_release -cs) \
|
||||
|
||||
## stable"
|
||||
|
||||
|
||||
```
|
||||
|
||||
>以上命令会添加稳定版本的 Docker APT 源,如果需要测试版本的 Docker 请将 stable 改为 test。
|
||||
|
||||
##### 报错解决办法
|
||||
#### 报错解决办法
|
||||
|
||||
在 `Raspberry Pi OS Bullseye/Bookworm` 中,添加 Docker 软件源的步骤可能会出现如下报错:
|
||||
|
||||
@@ -84,7 +101,10 @@ $ sudo echo "deb [arch=armhf] https://mirrors.aliyun.com/docker-ce/linux/raspbia
|
||||
|
||||
|
||||
## 官方源
|
||||
## $ sudo echo "deb [arch=armhf] https://download.docker.com/linux/raspbian $(lsb_release -cs) stable" | sudo tee -a /etc/apt/sources.list
|
||||
|
||||
## $ sudo echo "deb [arch=armhf] https://download.docker.com/linux/raspbian $(lsb_release -cs) stable" | sudo tee -a /etc/apt/sources.list
|
||||
|
||||
|
||||
```
|
||||
|
||||
#### 安装 Docker
|
||||
@@ -105,15 +125,20 @@ $ sudo apt-get install docker-ce
|
||||
|
||||
```bash
|
||||
## $ curl -fsSL test.docker.com -o get-docker.sh
|
||||
|
||||
$ curl -fsSL get.docker.com -o get-docker.sh
|
||||
$ sudo sh get-docker.sh --mirror Aliyun
|
||||
## $ sudo sh get-docker.sh --mirror AzureChinaCloud
|
||||
|
||||
|
||||
```
|
||||
|
||||
执行这个命令后,脚本就会自动的将一切准备工作做好,并且把 Docker 的稳定(stable)版本安装在系统中。
|
||||
|
||||
### 启动 Docker
|
||||
|
||||
运行以下命令:
|
||||
|
||||
```bash
|
||||
$ sudo systemctl enable docker
|
||||
$ sudo systemctl start docker
|
||||
@@ -139,6 +164,8 @@ $ sudo usermod -aG docker $USER
|
||||
|
||||
### 测试 Docker 是否安装正确
|
||||
|
||||
运行以下命令:
|
||||
|
||||
```bash
|
||||
$ docker run --rm hello-world
|
||||
|
||||
|
||||
Reference in New Issue
Block a user