docker使用阿里云镜像资源

更新你的现有列表包

1
sudo apt-get update

安装一些必要的系统工具

1
2
3
4
sudo apt-get install -y \
    apt-transport-https \
    ca-certificates \curl \
    software-properties-common

添加Docker官方GPG密钥(如果之前添加过可以跳过)

1
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

添加Docker官方软件源

1
2
3
4
sudo add-apt-repository \
   "deb [arch=arm64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

再次更新你的包列表

1
sudo apt-get update

现在,可以安装Docker了

1
sudo apt-get install docker-ce

如果遇到一下错误

复制代码
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package docker-ce is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  docker-ce-cli:arm64

E: Package 'docker-ce' has no installation candidate
复制代码

更改镜像源

//打开如下列表:
sudo vim /etc/apt/sources.list
 
//将原始的 Docker 源地址 https://download.docker.com/linux/ubuntu 替换为一个可用的镜像源地址。例如,阿里云的 Docker 镜像源为:
 
deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal stable
 
sudo apt-get update

验证是否成功安装了docker

1
docker --version

然后尝试拉取 hub.docker.com 的镜像 发现 速度龟速,因为是海外 有墙,所以配置镜像加速器

修改Docker配置文件

1
2
3
4
5
vim /etc/docker/daemon.json
然后添加如下内容
{
  "registry-mirrors": ["https://b2w3942p.mirror.aliyuncs.com"]
}

 然后重启docker 

1
2
sudo systemctl daemon-reload
sudo systemctl restart docker

  如果需要使用服务编排 docker-compose.yml 安装如下

1
apt install docker-compose

docker添加用户

第一步:sudo gpasswd -a username docker #将普通用户username加入到docker组中,username这个字段也可以直接换成$USER。

第二步:newgrp docker #更新docker组

第三步:再执行你报错的命令,此时就不会报错了。1

posted @   lzy1666  阅读(320)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示