美文网首页
Ubuntu使用apt国内源并安装docker(阿里源/清华源)

Ubuntu使用apt国内源并安装docker(阿里源/清华源)

作者: 南瓜pump | 来源:发表于2022-07-27 10:56 被阅读0次
  • 备份现有sources.list
cp /etc/apt/sources.list /etc/apt/sources.list.backup
  • 修改sources.list以更新apt源(根据网络情况选择使用阿里源或者清华源)
# 阿里源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

# 清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
  • 更新软件包
apt -y update
  • 修改Docker镜像源(可选择阿里源或者清华源)
## 使用阿里源
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | apt-key add - #安装GPG证书
add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" #写入docker-ce软件源信息

## 使用清华源
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - #安装GPG证书
add-apt-repository "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable" #写入docker-ce软件源信息
  • 再次更新软件包
apt -y update
  • 安装Docker
apt install docker-ce
  • 配置docker-mirror为本地源
echo '{ "registry-mirrors": ["https://ra9q5uam.mirror.aliyuncs.com"] }' > /etc/docker/daemon.json
# 其中https://ra9q5uam.mirror.aliyuncs.com为阿里源镜像地址,也可以更换为一下地址:
# docker中国区官方镜像:https://registry.docker-cn.com
# 网易镜像:http://hub-mirror.c.163.com
  • 重启docker服务
service docker restart

相关文章

网友评论

      本文标题:Ubuntu使用apt国内源并安装docker(阿里源/清华源)

      本文链接:https://www.haomeiwen.com/subject/mhfzirtx.html