docker使用阿里云镜像资源
更新你的现有列表包
sudo apt-get update
安装一些必要的系统工具
sudo apt-get install -y \
apt-transport-https \
ca-certificates \curl \
software-properties-common
添加Docker官方GPG密钥(如果之前添加过可以跳过)
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
添加Docker官方软件源
sudo add-apt-repository \ "deb [arch=arm64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \ $(lsb_release -cs) \ stable"
再次更新你的包列表
sudo apt-get update
现在,可以安装Docker了
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
docker --version
然后尝试拉取 hub.docker.com 的镜像 发现 速度龟速,因为是海外 有墙,所以配置镜像加速器
修改Docker配置文件
vim /etc/docker/daemon.json
然后添加如下内容
{
"registry-mirrors": ["https://b2w3942p.mirror.aliyuncs.com"]
}
然后重启docker
sudo systemctl daemon-reload sudo systemctl restart docker
如果需要使用服务编排 docker-compose.yml 安装如下
apt install docker-compose
docker添加用户
第一步:sudo gpasswd -a username docker #将普通用户username加入到docker组中,username这个字段也可以直接换成$USER。
第二步:newgrp docker #更新docker组
第三步:再执行你报错的命令,此时就不会报错了。1
浙公网安备 33010602011771号