Centos7.0 配置docker 镜像加速
Posted YatHo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos7.0 配置docker 镜像加速相关的知识,希望对你有一定的参考价值。
在Docker Hub官网上注册帐号,即可下载使用仓库里的全部的docker镜像。而因为网络原因,国内的开发者没办法流畅的下载镜像,经常会出现下载中断的错误。解决方法就是使用国内的容器Hub加速服务,本质就是更改pull优先级较高的服务器为国内的站点。
公司下载镜像实在太慢,无语了只能换镜像加速地址了。
国内docker镜像加速站
系统环境
操作系统: CentOS 7
docker版本: 1.9.1
[[email protected] docker]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) [[email protected] docker]# docker version Client: Version: 1.12.6 API version: 1.24 Package version: docker-1.12.6-61.git85d7426.el7.centos.x86_64 Go version: go1.8.3 Git commit: 85d7426/1.12.6 Built: Tue Oct 24 15:40:21 2017 OS/Arch: linux/amd64 Server: Version: 1.12.6 API version: 1.24 Package version: docker-1.12.6-61.git85d7426.el7.centos.x86_64 Go version: go1.8.3 Git commit: 85d7426/1.12.6 Built: Tue Oct 24 15:40:21 2017 OS/Arch: linux/amd64
DaoCloud加速
DaoCloud现在是提供一个一键脚本配置registry-mirror,这尼玛有坑,配了后我就启动不了服务了。
[[email protected] docker]# service docker restart Redirecting to /bin/systemctl restart docker.service Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details. [[email protected] docker]# systemctl status docker.service ?.docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Mon 2017-11-20 10:59:29 CST; 6s ago Docs: http://docs.docker.com Process: 11986 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIES (code=exited, status=1/FAILURE) Main PID: 11986 (code=exited, status=1/FAILURE) Nov 20 10:59:29 vm-50-151 systemd[1]: Starting Docker Application Container Engine... Nov 20 10:59:29 vm-50-151 dockerd-current[11986]: time="2017-11-20T10:59:29+08:00" level=fatal msg="unable to configure the Docker daemon with file /etc/docker/daemon.json: invalid character ‘}‘ loo... key string\n" Nov 20 10:59:29 vm-50-151 systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE Nov 20 10:59:29 vm-50-151 systemd[1]: Failed to start Docker Application Container Engine. Nov 20 10:59:29 vm-50-151 systemd[1]: Unit docker.service entered failed state. Nov 20 10:59:29 vm-50-151 systemd[1]: docker.service failed. Hint: Some lines were ellipsized, use -l to show in full.
测试后发现,是/etc/docker/daemon.json 文件李的json格式存在问题,直接手动修改
vi /etc/docker/daemon.json
修改后
[[email protected] docker]# cat /etc/docker/daemon.json { "registry-mirrors": [ "http://9aba2c9f.m.daocloud.io" ], "insecure-registries": [] }
重启服务器
[[email protected] docker]# service docker restart Redirecting to /bin/systemctl restart docker.service
搜索镜像
[[email protected] docker]# docker search mysql INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED docker.io docker.io/mysql MySQL is a widely used, open-source relati... 5249 [OK] docker.io docker.io/mariadb MariaDB is a community-developed fork of M... 1628 [OK] docker.io docker.io/mysql/mysql-server Optimized MySQL Server Docker images. Crea... 367 [OK] docker.io docker.io/percona Percona Server is a fork of the MySQL rela... 301 [OK]
经过使用测试:下载docker镜像时不再出现下载失败提示,粗略估计下载速度在200k/s左右,基本满足使用需求。
以上是关于Centos7.0 配置docker 镜像加速的主要内容,如果未能解决你的问题,请参考以下文章