sudo apt-get remove docker \ docker-engine \ docker.io
sudo apt-get update sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg \ lsb-release
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
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
sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo systemctl enable docker sudo systemctl start docker
sudo groupadd docker #添加docker组 sudo usermod -aG docker $USER #将当前用户加入docker组
docker run --rm hello-world
重要:设置Docker镜像加速
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/
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