Talking is cheap, show you the code.
- 删除系统中自带的旧版docker
sudo apt-get remove docker docker-engine docker.io containerd runc
- 安装依赖
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
- 添加docker的官方源
# 添加GPG Key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# 添加源
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- 安装docker
sudo apt-get -y install docker-ce docker-ce-cli containerd.io
- 验证
sudo docker -v
若显示正确版本号,搞定!
- 配置国内加速镜像
# 配置加速镜像
sudo echo -e '{"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn", "https://hub-mirror.c.163.com"]}' > /etc/docker/daemon.json
# 重启服务
sudo systemctl restart docker.service