栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > 服务器

docker 镜像加速CentOS7详细介绍

服务器 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

docker 镜像加速CentOS7详细介绍

前言

在Docker Hub官网上注册帐号,即可下载使用仓库里的全部的docker镜像。而因为网络原因,国内的开发者没办法流畅的下载镜像,经常会出现下载中断的错误。解决方法就是使用国内的容器Hub加速服务,本质就是更改pull优先级较高的服务器为国内的站点。

国内docker镜像加速站

阿里云
DaoCloud
灵雀云

系统环境

操作系统: CentOS 7
docker版本: 1.9.1

DaoCloud加速

DaoCloud现在是提供一个一键脚本配置registry-mirror,然而对于上述环境是不起作用的。

执行docker守护服务的help命令,发现没有–registry-mirror这个选项,而是使用–add-registry选项。

具体命令如下:

$ sudo docker daemon -h

Usage: docker daemon [OPTIONS]

Enable daemon mode

 --add-registry=[]   Registry to query before a public one
 --api-cors-header=   Set CORS headers in the remote API
 -b, --bridge=     Attach containers to a network bridge
 --bip=  Specify network bridge IP
 --block-registry=[]  Don't contact given registry
 --cluster-advertise=  Address or interface name to advertise
 --cluster-store=    Set the cluster store
 --cluster-store-opt=map[]      Set cluster store options
 --/confirm/i-def-push=trueConfirm a push to default registry
 -D, --debug=false   Enable debug mode
 --default-gateway=   Container default gateway IPv4 address
 --default-gateway-v6= Container default gateway IPv6 address
 --default-ulimit=[]  Set default ulimits for containers
 --disable-legacy-registry=false   Do not contact legacy registries
 --dns=[] DNS server to use
 --dns-opt=[]      DNS options to use
 --dns-search=[]    DNS search domains to use
 -e, --exec-driver=nativeExec driver to use
 --exec-opt=[]     Set exec driver options
 --exec-root=/var/run/docker     Root of the Docker execdriver
 --fixed-cidr=     IPv4 subnet for fixed IPs
 --fixed-cidr-v6=    IPv6 subnet for fixed IPs
 -G, --group=docker   Group for the unix socket
 -g, --graph=/var/lib/docker     Root of the Docker runtime
 -H, --host=[]     Daemon socket(s) to connect to
 --help=false      Print usage
 --icc=trueEnable inter-container communication
 --insecure-registry=[] Enable insecure registry communication
 --ip=0.0.0.0      Default IP when binding container ports
 --ip-forward=true   Enable net.ipv4.ip_forward
 --ip-masq=true     Enable IP masquerading
 --iptables=true    Enable addition of iptables rules
 --ipv6=false      Enable IPv6 networking
 -l, --log-level=info  Set the logging level
 --label=[]Set key=value labels to the daemon
 --log-driver=json-file Default driver for container logs
 --log-opt=map[]    Set log driver options
 --mtu=0 Set the containers network MTU
 -p, --pidfile=/var/run/docker.pid  Path to use for daemon PID file
 --registry-mirror=[]  Preferred Docker registry mirror
 -s, --storage-driver= Storage driver to use
 --selinux-enabled=falseEnable selinux support
 --storage-opt=[]    Set storage driver options
 --tls=false      Use TLS; implied by --tlsverify
 --tlscacert=~/.docker/ca.pem     Trust certs signed only by this CA
 --tlscert=~/.docker/cert.pem     Path to TLS certificate file
 --tlskey=~/.docker/key.pem      Path to TLS key file
 --tlsverify=false   Use TLS and verify the remote
 --userland-proxy=true Use userland proxy for loopback traffic

在文件/etc/sysconfig/docker中增加以下代码:

ADD_REGISTRY='--add-registry [你的加速站网址]'

然后,重启Docker就可以了。

sudo systemctl daemon-reload 

sudo service docker restart

使用镜像加速

1.拉取镜像前请先登录: docker login daocloud.io(请使用用户名进行 login)

2.docker pull [你需要的镜像]

后续

经过使用测试:下载docker镜像时不再出现下载失败提示,粗略估计下载速度在200k/s左右,基本满足使用需求。

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/182297.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号