centos7 docker使用https_proxy 代理配置

centos7 docker使用https_proxy 代理配置

背景:
    内网的centos主机不能上网,通过同网段的windows设置代理上网,yum.conf配置http代理是可以的,但是docker无法拉取镜像

处理办法:
    如果是centos6版本只需要在/etc/sysconfig/docker 配置文件里面增加配置即可
    centos7 使用systemd 来管理进程环境,我们需要如下配置来应用https_proxy

创建目录

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


2.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 808 (#0)
*   Trying 10.11.0.148...
* Connected to 10.11.0.148 (10.11.0.148) port 808 (#0)
> GET http://www.baidu.com/ HTTP/1.1
> User-Agent: curl/7.29.0
> 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=
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值