• Centos7.0 配置docker 镜像加速


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

    公司下载镜像实在太慢,无语了只能换镜像加速地址了。

    国内docker镜像加速站

    系统环境

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

    [root@vm-50-151 docker]# cat /etc/redhat-release 
    CentOS Linux release 7.4.1708 (Core) 
    [root@vm-50-151 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加速

      http://guide.daocloud.io/dcs/daocloud-9153151.html

      DaoCloud现在是提供一个一键脚本配置registry-mirror,这尼玛有坑,配了后我就启动不了服务了。

    [root@vm-50-151 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.
    [root@vm-50-151 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
    "
    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
    

      修改后

    [root@vm-50-151 docker]# cat  /etc/docker/daemon.json
    {
        "registry-mirrors": [
           "http://9aba2c9f.m.daocloud.io"
        ],
        "insecure-registries": []
    }
    

      重启服务器

    [root@vm-50-151 docker]# service docker restart
    Redirecting to /bin/systemctl restart docker.service
    

      搜索镜像

    [root@vm-50-151 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左右,基本满足使用需求。

  • 相关阅读:
    linux中内存使用,swap,cache,buffer的含义总结
    haproxy启动时提示失败
    pcs与crmsh命令比较
    用yum下载rpm包(不安装)到指定目录
    Openstack的镜像属性
    ceph 对接openstack liberty
    ceph 创建和删除osd
    linux之fstab文件详解
    OpenStack Swift集群部署流程与简单使用
    swift(Object Storage对象存储服务)(单节点)
  • 原文地址:https://www.cnblogs.com/YatHo/p/7865385.html
Copyright © 2020-2023  润新知