创建并编辑文件
[root@localhost ~]# cd /etc/docker/ [root@localhost docker]# [root@localhost docker]# ls key.json [root@localhost docker]#
# vi daemon.json
[root@localhost docker]# pwd /etc/docker [root@localhost docker]# [root@localhost docker]# cat daemon.json { "registry-mirrors": ["https://hub.daocloud.io"] }
或者
https://almtd3fa.mirror.aliyuncs.com为阿里云的加速地址。修改后,重启docker
{ "registry-mirrors": ["https://almtd3fa.mirror.aliyuncs.com"] }
重启服务
# systemctl daemon-reload
# systemctl restart docker.service
验证:
# docker info
[root@localhost docker]# docker info Client: Debug Mode: false Server: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 19.03.1 Storage Driver: overlay2 Backing Filesystem: xfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs 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: runc Default Runtime: runc Init Binary: docker-init containerd version: 894b81a4b802e4eb2a91d1ce216b8817763c29fb runc version: 425e105d5a03fabd737a126ad93d62a9eeede87f init version: fec3683 Security Options: seccomp Profile: default Kernel Version: 3.10.0-862.el7.x86_64 Operating System: CentOS Linux 7 (Core) OSType: linux Architecture: x86_64 CPUs: 8 Total Memory: 31.26GiB Name: localhost.localdomain ID: PWEZ:N4ZR:KMJC:EGZ7:EAPB:MU7P:OA5U:42IT:3HI3:7QU6:WL2J:FKKT 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://hub.daocloud.io/ Live Restore Enabled: false
参考文章:
CoreOS配置Docker镜像加速器更靠谱的方法
https://yq.aliyun.com/articles/622254?spm=5176.10695662.1996646101.searchclickresult.39e63908A9XO6Z
Docker 镜像加速器
https://yq.aliyun.com/articles/29941?spm=5176.10695662.1996646101.searchclickresult.39e63908A9XO6Z