错误重现:
添加docker官方GPG密钥
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"
错误信息:
W: Failed to fetch https://download/docker.com/linux/ubuntu/dists/bionic/InRelease Could not resolve 'download'
W: Some index files failed to download. They have been ignored, or old ones used instead.
错误分析:
使用的是docker官方源安装,国内网络的原因导致可能无法访问,按照网上的方法直接设置DNS后无效。
解决:
如果已经添加过官方的源执行失败,需要在/etc/apt/sources.list里删掉最后docker官方的源链接
sudo vi /etc/apt/sources.list
不然你每次sudo apt-get update 都会出错,删除完成后执行下面的命令将docker官方源修改为阿里云源:
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
$(lsb_release -cs) \
stable"
更换国内源后一切正常。