centos7 docker使用https_proxy 代理配置

背景:
内网的centos主机不能上网,通过同网段的windows设置代理上网,yum.conf配置http代理是可以的,但是docker无法拉取镜像 处理办法:
如果是centos6版本只需要在/etc/sysconfig/docker 配置文件里面增加配置即可
centos7 使用systemd 来管理进程环境,我们需要如下配置来应用https_proxy # 设置代理
http_proxy=http://10.11.0.148:808
https_proxy="https://10.11.0.148:808"
export ftp_proxy=http://10.11.0.148:808
export socks_proxy="socks://10.11.0.148:808/"
export http_proxy=http://10.11.0.148:808
export https_proxy=https://10.11.0.148:808 创建目录 mkdir /etc/systemd/system/docker.service.d
创建文件
vim /etc/systemd/system/docker.service.d/http-proxy.conf 配置http-proxy.conf文件增加以下内容 [Service]
Environment="HTTP_PROXY=http://10.11.0.148:808"
daemon重新reload 并重启docker systemctl daemon-reload
systemctl restart docker
检查变量是否加载 systemctl show docker --property Environment .curl命令添加http和https代理
默认使用curl命令在代理模式下是无法使用的,需要在bash命令行下添加代理 export http_proxy=http://10.11.0.148:808
export https_proxy=https://10.11.0.148:808 [root@node1 hello-world]# curl -vv http://www.baidu.com
* About to connect() to proxy 10.11.0.148 port (#)
* Trying 10.11.0.148...
* Connected to 10.11.0.148 (10.11.0.148) port (#)
> GET http://www.baidu.com/ HTTP/1.1
> User-Agent: curl/7.29.
> Host: www.baidu.com
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
< Connection: Keep-Alive
< Content-Length: 2381
< Content-Type: text/html
< Date: Tue, 12 Jun 2018 01:14:04 GMT
< Etag: "588604dd-94d"
< Last-Modified: Mon, 23 Jan 2017 13:27:57 GMT
< Pragma: no-cache
< Server: bfe/1.0.8.18
< Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/
<
<!DOCTYPE html>
<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>百度一下,你就知道</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f value=8> <input type=hidden name=rsv_bp value=1> <input type=hidden name=rsv_idx value=1> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus></span><span class="bg s_btn_wr"><input type=submit id=su value=百度一下 class="bg s_btn"></span> </form> </div> </div> <div id=u1> <a href=http://news.baidu.com name=tj_trnews class=mnav>新闻</a> <a href=http://www.hao123.com name=tj_trhao123 class=mnav>hao123</a> <a href=http://map.baidu.com name=tj_trmap class=mnav>地图</a> <a href=http://v.baidu.com name=tj_trvideo class=mnav>视频</a> <a href=http://tieba.baidu.com name=tj_trtieba class=mnav>贴吧</a> <noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&amp;tpl=mn&amp;u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>登录</a> </noscript> <script>document.write('<a href="http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === "" ? "?" : "&")+ "bdorz_come=1")+ '" name="tj_login" class="lb">登录</a>');</script> <a href=//www.baidu.com/more/ name=tj_briicon class=bri style="display: block;">更多产品</a> </div> </div> </div> <div id=ftCon> <div id=ftConw> <p id=lh> <a href=http://home.baidu.com>关于百度</a> <a href=http://ir.baidu.com>About Baidu</a> </p> <p id=cp>&copy;2017&nbsp;Baidu&nbsp;<a href=http://www.baidu.com/duty/>使用百度前必读</a>&nbsp; <a href=http://jianyi.baidu.com/ class=cp-feedback>意见反馈</a>&nbsp;京ICP证030173号&nbsp; <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>
* Connection #0 to host 10.11.0.148 left intact [root@node1 ~]# curl --head https://www.baidu.com
HTTP/1.1 200 Connection established
Proxy-agent: CCProxy HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Connection: Keep-Alive
Content-Length: 277
Content-Type: text/html
Date: Tue, 12 Jun 2018 05:58:58 GMT
Etag: "575e1f71-115"
Last-Modified: Mon, 13 Jun 2016 02:50:25 GMT
Pragma: no-cache
Server: bfe/1.0.8.18 [root@node1 ~]# curl -vv https://www.baidu.com
* About to connect() to proxy 10.11.0.148 port 808 (#0)
* Trying 10.11.0.148...
* Connected to 10.11.0.148 (10.11.0.148) port 808 (#0)
* Establish HTTP proxy tunnel to www.baidu.com:443
> CONNECT www.baidu.com:443 HTTP/1.1
> Host: www.baidu.com:443
> User-Agent: curl/7.29.0
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 Connection established
< Proxy-agent: CCProxy
<
* Proxy replied OK to CONNECT request
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate:
* subject: CN=baidu.com,OU=service operation department.,O="BeiJing Baidu Netcom Science Technology Co., Ltd",L=beijing,ST=beijing,C=CN
* start date: Jun 29 00:00:00 2017 GMT
* expire date: Aug 17 23:59:59 2018 GMT
* common name: baidu.com
* issuer: CN=Symantec Class 3 Secure Server CA - G4,OU=Symantec Trust Network,O=Symantec Corporation,C=US
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: www.baidu.com
> Accept: */*
>
< HTTP/1.1 OK
< Accept-Ranges: bytes
< Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
< Connection: Keep-Alive
< Content-Length:
< Content-Type: text/html
< Date: Tue, Jun :: GMT
< Etag: "588603f3-98b"
< Last-Modified: Mon, Jan :: GMT
< Pragma: no-cache
< Server: bfe/1.0.8.18
< Set-Cookie: BDORZ=; max-age=; domain=.baidu.com; path=/
<
<!DOCTYPE html>
<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/bdorz/baidu.min.css><title>百度一下,你就知道</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f value=8> <input type=hidden name=rsv_bp value=1> <input type=hidden name=rsv_idx value=1> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus=autofocus></span><span class="bg s_btn_wr"><input type=submit id=su value=百度一下 class="bg s_btn" autofocus></span> </form> </div> </div> <div id=u1> <a href=http://news.baidu.com name=tj_trnews class=mnav>新闻</a> <a href=https://www.hao123.com name=tj_trhao123 class=mnav>hao123</a> <a href=http://map.baidu.com name=tj_trmap class=mnav>地图</a> <a href=http://v.baidu.com name=tj_trvideo class=mnav>视频</a> <a href=http://tieba.baidu.com name=tj_trtieba class=mnav>贴吧</a> <noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&amp;tpl=mn&amp;u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>登录</a> </noscript> <script>document.write('<a href="http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === "" ? "?" : "&")+ "bdorz_come=1")+ '" name="tj_login" class="lb">登录</a>');
</script> <a href=//www.baidu.com/more/ name=tj_briicon class=bri style="display: block;">更多产品</a> </div> </div> </div> <div id=ftCon> <div id=ftConw> <p id=lh> <a href=http://home.baidu.com>关于百度</a> <a href=http://ir.baidu.com>About Baidu</a> </p> <p id=cp>&copy;2017&nbsp;Baidu&nbsp;<a href=http://www.baidu.com/duty/>使用百度前必读</a>&nbsp; <a href=http://jianyi.baidu.com/ class=cp-feedback>意见反馈</a>&nbsp;京ICP证030173号&nbsp; <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>
* Connection # to host 10.11.0.148 left intact

centos7 docker使用https_proxy 代理配置的更多相关文章

  1. 使用python自动生成docker nginx反向代理配置

    由于在测试环境上用docker部署了多个应用,而且他们的端口有的相同,有的又不相同,数量也比较多,在使用jenkins发版本的时候,不好配置,于是想要写一个脚本,能在docker 容器创建.停止的时候 ...

  2. Centos7 docker、harbor 安装配置

    Docker 安装 wget -O /etc/yum.repos.d/epel.repo http://mirrors.cloud.tencent.com/repo/epel-7.repo wget ...

  3. Docker的三种网络代理配置

    开源Linux 长按二维码加关注~ 上一篇:IPv6技术白皮书(附PDF下载) 有时因为网络原因,比如公司NAT,或其它啥的,需要使用代理.Docker的代理配置,略显复杂,因为有三种场景.但基本原理 ...

  4. centos7 docker 安装配置

    docker快速入门测试 ########################################## #docker安装配置 #环境centos7 #配置docker阿里源 echo '#D ...

  5. Centos7 Docker配置TLS认证的远程端口的证书生成教程(shell脚本一键生成)

    通过 TLS来进行远程访问 百度百科 - TLS.我们需要在远程 docker 服务器(运行 docker 守护进程的服务器)生成 CA 证书,服务器证书,服务器密钥,然后自签名,再颁发给需要连接远程 ...

  6. Centos7搭建SS以及加速配置的操作记录 (转载)

    原文地址https://www.cnblogs.com/kevingrace/p/8495424.html 部署 Shadowsocks之前,对它做了一个简单的了解,下面先介绍下.一道隐形的墙众所周知 ...

  7. Centos7搭建SS以及加速配置的操作记录

    部署 Shadowsocks之前,对它做了一个简单的了解,下面先介绍下.一道隐形的墙众所周知,天朝局域网通过 GFW (中国防火墙长城:英文名称Great Firewall of China,简写为G ...

  8. CentOS7 Docker私有仓库搭建及删除镜像 【转】

    文章来源:centos7 Docker私有仓库搭建及删除镜像 如果不想用私有镜像库,你可以用docker的库 https://hub.docker.com 环境准备 环境:两个装有Docker 17. ...

  9. tinyproxy代理配置

    tinyproxy代理配置 应用场景: 生产机处于内网,无法直接访问外网,程序安装和漏洞修复等操作需要进行联网操作:通过在办公网(可访问外网)上设置代理服务器,生产机通过代理由办公网访问外网 代理服务 ...

随机推荐

  1. ArcGis Python脚本——批量对影像、要素类定义投影

    这一段是批量定义要素类(FeatureClasses)投影的ArcPy代码: 把要处理的要素类塞进一个文件夹(工作空间,workspace),然后将代码开头的路径换成这个“文件夹”的路径,处理完后再做 ...

  2. SQL Server进阶(八)查询——开窗函数、四大排名函数、透视数据、逆透视数据

    概述 ROW_NUMBER() OVER(PARTITION BY CustId ORDER BY ID DESC) https://www.jb51.net/article/75533.htm 开窗 ...

  3. DingDing的CorpSecretID和SSOSecret不是一个东西

    今天客户更新系统后,提供了一对corpid和secret,结果同步钉钉考勤机数据时,一直提示corpid和secret不正确,最后询问钉钉官方人员发现,客户提供的是SSOSecret,应该使用Copr ...

  4. VS 在文件中查找替换界面死掉。

    主要问题时一个CopyAndReplace的插件引起的.卸载掉就没问题了.

  5. 什么是CMD

    cmd是command的缩写.命令提示符是在操作系统中,提示进行命令输入的一种工作提示符.在不同的操作系统环境下,命令提示符各不相同. 在windows环境下,命令行程序为cmd.exe,是一个32位 ...

  6. mysql-router的安装与使用

    1.下载 https://dev.mysql.com/get/Downloads/MySQL-Router/mysql-router-2.0.4-linux-glibc2.12-x86-64bit.t ...

  7. mysql5.7安装(正确安装)实战

    一.二进制免编译包安装  参考:http://www.apelearn.com/bbs/forum.php?mod=viewthread&tid=10105&highlight=mys ...

  8. Django REST framework 第一章 Serialization

    此章节将会介绍多种构成REST framework的重要模块,在每个部分如何一起配合上提供一个综合的全方面的了解. 准备 同样的创建一个新项目,创建一个新的app,将rest_framework跟新建 ...

  9. 【Git】Git常用命令

    git remote -v : 查看远程仓库地址

  10. 《Javascript高级程序设计》第六章笔记整理

    一.创建对象的方法(6种) 1.工厂模式 即用函数来封装以特定接口创建对象的细节. function createPerson(name,age,job){ var o = new Object(); ...