Ubuntu20下载安装Docker
作者:互联网
安装Docker
- 卸载旧版本
sudo apt-get remove docker \
docker-engine \
docker.io
- 使用apt安装
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
- 添加软件源GPG秘钥
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- 添加docker软件源
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- 安装Docker
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
- 启动Docker
sudo systemctl enable docker
sudo systemctl start docker
- 建立用户组并将当前用户加入docker组
sudo groupadd docker #添加docker组
sudo usermod -aG docker $USER #将当前用户加入docker组
- 测试Docker是否安装正确
docker run --rm hello-world
重要:设置Docker镜像加速
- 查看是否为docker.service中配置过镜像地址
systemctl cat docker | grep '\-\-registry\-mirror'
- 具体配置如下:在
/etc/docker/daemon.json
中写入以下内容
{
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com"
]
}
- 重启服务
sudo systemctl daemon-reload
sudo systemctl restart docker
- 使用
docker info
查看加速器是否生效
Registry Mirrors:
https://hub-mirror.c.163.com/
卸载Docker
sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
标签:https,get,sudo,apt,下载安装,Docker,Ubuntu20,docker 来源: https://www.cnblogs.com/cs-code/p/16614483.html