环境说明
本人使用的镜像版本为:
2020-05-27-raspios-buster-full-armhf.img
注意镜像文件名里包含的参数(在修改镜像源时会用到):
buster
armhf
查看本系统参数
pi@raspberrypi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10 (buster)
Release: 10
Codename: buster
镜像源:清华大学开源镜像
更新国内清华大学源方法看另一篇文章:https://blog.csdn.net/peking2009/article/details/107282595
1、更新环境软件所
sudo apt-get update
sudo apt-get dist-update -y
2、安装依赖项:
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
3、使用官方脚本自动安装
curl -fsSL https://get.docker.com | bash -s docker
4、添加用户组和用户
#添加docker用户组,可能已经存在,已存在就可以直接进行下一步
sudo groupadd docker
#将当前登录用户(pi)加入到docker用户组中
sudo gpasswd -a $USER docker
#更新用户组
sudo newgrp docker
5、重启 docker 服务
$ sudo service docker restart
6、查看版本
pi@raspberrypi:/ $ docker -v
Docker version 19.03.12, build 48a6621
pi@raspberrypi:/ $ docker version
Client: Docker Engine - Community
Version: 19.03.12
API version: 1.40
Go version: go1.13.10
Git commit: 48a6621
Built: Mon Jun 22 15:53:41 2020
OS/Arch: linux/arm
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.12
API version: 1.40 (minimum version 1.12)
Go version: go1.13.10
Git commit: 48a6621
Built: Mon Jun 22 15:47:34 2020
OS/Arch: linux/arm
Experimental: false
containerd:
Version: 1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
7、运行hello-world容器
pi@raspberrypi:/ $ docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(arm32v7)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
出现以下内容证明docker安装成功。
8、使用pip安装docker-compose
2020-05-27-raspios-buster-full-armhf.img镜像自带两个版本的python分别是2.7和3.7
pi@raspberrypi:~ $ pip -V
pip 18.1 from /usr/lib/python2.7/dist-packages/pip (python 2.7)
pi@raspberrypi:~ $ pip3 -V
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)
我们使用pip3进行安装(我安装了差不多1个小时)
sudo pip3 -v install docker-compose
注意:不带-v参数安装了好几次都卡到半路不走。cpu消耗100%
后来添加了参数-v安装成功,虽然比较耗时但最终还是安装成功了。
查看docker-compse版本:
pi@raspberrypi:~ $ docker-compose version
docker-compose version 1.26.2, build unknown
docker-py version: 4.2.2
CPython version: 3.7.3
OpenSSL version: OpenSSL 1.1.1d 10 Sep 2019