v2ray 加速docker拉取镜像

作者: 777930641f9e | 来源:发表于2020-03-08 14:10 被阅读0次

    1. 下载v2ray软件包

    wget https://github.com/v2ray/v2ray-core/releases/download/v4.22.1/v2ray-linux-64.zip
    

    2. 解压缩软件包

     unzip v2ray-linux-64.zip 
    

    3. 写入客户端配置

    具体参数根据你的服务器设定来

    cat  config.json
    {
      "policy" : {
        "levels" : {
          "0" : {
            "uplinkOnly" : 0
          }
        }
      },
      "dns" : {
        "servers" : [
          "localhost"
        ]
      },
      "outboundDetour" : [
        {
          "protocol" : "freedom",
          "tag" : "direct",
          "settings" : {
    
          }
        }
      ],
      "inbound" : {
        "listen" : "0.0.0.0",
        "port" : 1081,
        "protocol" : "socks",
        "settings" : {
          "auth" : "noauth",
          "udp" : false,
          "ip" : "127.0.0.1"
        }
      },
      "inboundDetour" : [
        {
          "listen" : "0.0.0.0",
          "allocate" : {
            "strategy" : "always",
            "refresh" : 5,
            "concurrency" : 3
          },
          "port" : 8001,
          "protocol" : "http",
          "tag" : "httpDetour",
          "domainOverride" : [
            "http",
            "tls"
          ],
          "streamSettings" : {
    
          },
          "settings" : {
            "timeout" : 0
          }
        }
      ],
      "routing" : {
        "strategy" : "rules",
        "settings" : {
          "domainStrategy" : "IPIfNonMatch",
          "rules" : [
            {
              "domain" : [
                "localhost"
              ],
              "type" : "field",
              "outboundTag" : "direct"
            },
            {
              "type" : "field",
              "outboundTag" : "direct",
              "ip" : [
                "geoip:private"
              ]
            }
          ]
        }
      },
      "outbound" : {
        "sendThrough" : "0.0.0.0",
        "mux" : {
          "enabled" : false,
          "concurrency" : 8
        },
        "protocol" : "vmess",
        "settings" : {
          "vnext" : [
            {
              "address" : "47.75.99.255",
              "port" : 49284,
              "users" : [
                {
                  "id" : "aa435739-8888-1111-7777-71a8010cff50",
                  "alterId" : 733,
                  "security" : "auto",
                  "level" : 0
                }
              ],
              "remark" : "rongge"
            }
          ]
        },
        "streamSettings" : {
          "wsSettings" : {
            "path" : "",
            "headers" : {
              "Host" : "youraddress.com"
            }
          },
          "tlsSettings" : {
            "serverName" : "youraddress.com",
            "allowInsecure" : false
          },
          "httpSettings" : {
            "path" : "",
            "host" : [
              ""
            ]
          },
          "tcpSettings" : {
            "header" : {
              "type" : "none"
            }
          },
          "kcpSettings" : {
            "header" : {
              "type" : "none"
            },
            "mtu" : 1350,
            "congestion" : false,
            "tti" : 20,
            "uplinkCapacity" : 5,
            "writeBufferSize" : 1,
            "readBufferSize" : 1,
            "downlinkCapacity" : 20
          },
          "network" : "tcp",
          "security" : "none"
        }
      }
    }
    

    4. 启动v2ray到后台运行

    ./v2ray --config=config.json &
    

    临时设置全局HTTP和HTTPS代理,该配置对docker加速镜像拉取无效,仅能用于网页访问加速,此处v2ray客户端和代理在同一台服务器,故使用127.0.0.1地址,局域网内其他服务器需要使用该代理,地址需修改为代理所在服务器内网IP,并检查iptables和安全组设置

    export https_proxy=https://127.0.0.1:8001
    export http_proxy=http://127.0.0.1:8001
    

    5. 创建文件

    mkdir /etc/systemd/system/docker.service.d
    

    6. 修改文件

    vim  /etc/systemd/system/docker.service.d/http-proxy.conf
    

    加入如下配置,设置docker使用HTTP代理,局域网内其服务器需要将127.0.0.1改为代理服务器IP

    [Service]
    Environment="HTTP_PROXY=http://127.0.0.1:8001"
    

    7. 重启服务

    systemctl daemon-reload
    systemctl restart docker
    

    8. 查看docker信息,是否包含HTTP代理信息

    docker info
    

    9. 拉取docker镜像测试加速效果

    docker pull gcr.io/google-containers/hpa-example:lastest
    

    相关文章

      网友评论

        本文标题:v2ray 加速docker拉取镜像

        本文链接:https://www.haomeiwen.com/subject/samddhtx.html