sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl status docker
如果状态是active,证明安装成功。
#修改配置文件
sudo vim /etc/docker/daemon.json
#添加以下内容
{
"registry-mirrors": [
#网易
"http://hub-mirror.c.163.com",
# 中科大
"https://docker.mirrors.ustc.edu.cn",
]
}
#重启docker
sudo service docker restart
我本人用的是阿里云的镜像,他家的源我一直比较喜欢,速度快。
进入网址:https://cr.console.aliyun.com/cn-wulanchabu/instances/mirrors
复制阿里提供的镜像源,填入/etc/docker/daemon.json
中即可。
检查是否换源成功:
sudo docker info
现在你就能快乐的使用docker啦~