1.删除旧版本
sudo apt-get remove docker docker-engine docker.io
2.安装 HTTPS
和 CA
支持套件
apt-get install apt-transport-https ca-certificates curl software-properties-common
3.添加 GPG
密钥
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg |sudo apt-key add -
4.向 source.list
添加 Docker
软件源
// 学习
sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable "
// 官方源
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable "
5.更新 apt
缓存
apt-get update
apt-get install docker-ce
测试环境下可以使用官方提供的脚本安装
curl -fsSL get.docker.com -o get-docker.sh
sudo sh get-docker.sh --mirror Aliyun
6.启动 Docker CE
systemctl enable docker
systemctl start docker
7.建立 Docker
用户组
docker 使用 Unix scoker
与 Docker
引擎通讯, 而只有 root
用户和 docker
组用户才可以访问。
sudo groupadd docker
8.将当前用户加入 docker
组
sudo usermod -aG docker $USER
9.测试 Docker
安装是否正确
sudo docker run hello-world
10.配置加速镜像
在 /etc/docker/daemon.json
中写入内容,没有则新建:
{
"registry-mirrors": [
"https://registry.docker-cn.com"
]
}
11.重启
sudo systemctl daemon-reload
sudo systemctl restart docker
[1] Docker 官方文档