Docker配置阿里云镜像加速器
一、登录阿里云控制台二、配置daemon.json三、查看docker info四、测试下载
·
一、登录阿里云控制台
登录阿里云后,搜索 容器镜像服务 ,如下图:
二、配置daemon.json
登录你的阿里云服务器,执行以下脚本,意思就是把镜像加速器的地址配置到 /etc/docker/daemon.json ,当然你不习惯的话,使用 vim /etc/docker/daemon.json 创建编辑也可以的。
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://xxxxxxxx.mirror.aliyuncs.com"]
}
EOF
注意哦,我这里的 https://xxxxxxxx.mirror.aliyuncs.com 这里要改成你自己的阿里云镜像加速器的地址也就是我上一步图示中的地址,接下里重新加载配置并重启docker,执行脚本如下:
#重新加载配置文件
sudo systemctl daemon-reload
#重启docker
sudo systemctl restart docker
三、查看docker info
怎么看呢?我们可以通过 docker info 查看我们的配置是否生效了。
#查看docker信息
docker info
运行结果:
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Build with BuildKit (Docker Inc., v0.6.3-docker)
scan: Docker Scan (Docker Inc., v0.12.0)
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 20.10.9
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
runc version: v1.0.2-0-g52b36a2
init version: de40ad0
Security Options:
seccomp
Profile: default
Kernel Version: 4.18.0-305.19.1.el8_4.x86_64
Operating System: CentOS Linux 8
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.649GiB
Name: iZwz95ftzhfl9qi3l12ckaZ
ID: 2R3N:ORPQ:WO2D:N7DS:CQSD:EJMD:BQMX:VXDW:FVC4:VWII:3CFN:MCFH
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://xxxxxxxx.mirror.aliyuncs.com/
Live Restore Enabled: false
结果的倒数第二行,我们看到Docker镜像仓库的地址了。
四、测试下载
我们通过 docker 下载 mysql-8.0.28 ,具体的版本需要去官网查看 https://hub.docker.com/_/mysql?tab=tags
#下载mysql-8.0.28
docker pull mysql:8.0.28
运行结果:
8.0.28: Pulling from library/mysql
6552179c3509: Pull complete
d69aa66e4482: Pull complete
3b19465b002b: Pull complete
7b0d0cfe99a1: Pull complete
9ccd5a5c8987: Pull complete
2dab00d7d232: Pull complete
64d3afdccd4a: Pull complete
82148d50b16c: Pull complete
8bb7d73a7d0c: Pull complete
74778cd68a75: Pull complete
d7e5f9309140: Pull complete
f2e376ecd59f: Pull complete
Digest: sha256:92d27b8222bbcf53bc42c70ca7cd1010d6c0527efc61f14980ce77c50932bef4
Status: Downloaded newer image for mysql:8.0.28
docker.io/library/mysql:8.0.28
确实比官网下载快多了,我们可以通过 docker images 查看我们刚下载的镜像
#查看镜像
docker images
运行结果:
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 8.0.28 d1dc36cf8d9e 3 weeks ago 519MB
更多推荐
已为社区贡献11条内容
所有评论(0)