1. Docker 安装
(注:整体参考 Docker 官方的安装教程:https://docs.docker.com/engine/install/debian/)
首先更新一下 apt-get,一个 Debian 下常用的包管理工具。
$ sudo apt-get update

使用 apt-get 安装一些之后需要的工具:
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common

添加 Docker 的官方 GPG key:
$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

添加完之后可以确认一下是否添加成功
$ sudo apt-key fingerprint 0EBFCD88

为 apt-get 添加 docker 官方的库地址
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"

添加完成后,再次更新 apt-get,并安装 docker 相关服务
sudo apt-get update && sudo apt-get install docker-ce docker-ce-cli containerd.io

检查一下 docker 是否正常运行
sudo docker run hello-world

如果出现类似以上内容,则代表运行正常。
2. Docker-compose 安装
Docker-compose 可以方便地部署多个 Docker 服务。
(注:安装方法主要参考:https://docs.docker.com/compose/install/)
安装 pip3
sudo apt-get pip3 -y
安装 docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
修改权限并进行软链接
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose