zoukankan      html  css  js  c++  java
  • 解决docker设置HTTP/HTTPS代理TLS handshake timeout

    背景:
    由于本地内网服务器的internet是受限制的(需要配置远程代理上网,不能直接上网)。因此,在使用docker连接docker hub的时候,就会出错。

    docker pull nginx(拉取dockerhub镜像)

    问题一:
    Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while aw

    解决方法:设置Http和Https代理
    mkdir -p /etc/systemd/system/docker.service.d
    vim /etc/systemd/system/docker.service.d/proxy.conf
    [Service]
    Environment="HTTP_PROXY=http://192.168.1.9:1080"
    Environment="HTTPS_PROXY=https://192.168.1.9:1080"

    注:
    HTTP_PROXY 和 HTTPS_PROXY 将它的值对应到您设置的代理服务地址和端口
    Environment="HTTP_PROXY=http://proxy.example.com:80"
    Environment="HTTPS_PROXY=https://proxy.example.com:443"


    刷新更改并重新启动Docker
    systemctl daemon-reload
    systemctl restart docker

    参考文档:https://docs.docker.com/config/daemon/systemd/

    ## https://www.cnblogs.com/liucx/

    2.设置代理后,仍然无法拉取镜像

    问题二:
    Docker pull:TLS握手超时

    Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

    但是使用curl TLS可以正常工作
    curl https://registry-1.docker.io/v2/
    {"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":null}]}

    在网络上搜索了半天,基本是设置docker加速器或者修改MTU大小

    ## https://www.cnblogs.com/liucx/

    最后解决方法:
    将https代理的地址 改成 http//网址
    vim /etc/systemd/system/docker.service.d/proxy.conf
    [Service]
    Environment="HTTP_PROXY=http://192.168.1.9:1080"
    Environment="HTTPS_PROXY=http://192.168.1.9:1080"

    刷新更改并重新启动Docker
    systemctl daemon-reload
    systemctl restart docker

    现在一切正常,希望能帮到您,帮忙点个赞哈

    作者:Liucx
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
  • 相关阅读:
    FATAL ERROR: please install the following Perl modules before executing /usr/bin/mysql_install_db:
    redis分布式锁原理与实现
    java中如何将 string 转化成 long
    FastJson中JSONObject用法及常用方法总结
    Spring IOC 一——容器装配Bean的简单使用
    静态代理和动态代理
    Spring AOP——Spring 中面向切面编程
    什么是分布式锁?实现分布式锁的三种方式
    @Consumes @Produces的作用
    pro、pre、test、dev环境
  • 原文地址:https://www.cnblogs.com/liucx/p/14681228.html
Copyright © 2011-2022 走看看