如何为Docker build设置http_proxy

我的Linux机器在公司里是通过http proxy连接Internet的。通过export http_proxy=http://proxyhost:proxyport来上网。


但执行Docker build时,执行过程中提示连接不到网络。后来找到三种办法。

      1. 在Docker file 里面写上,ENV http_proxy http://proxyhost:proxyport。

           但这样的话,就把http_proxy写死到dockerfile中了。使用这个image的人就麻烦了,他要通过这样的方式来run。    

      docker run --env http_proxy=http://10.128.46.150:3128/ my/http-client

2. 对第一种方法改进。在在Docker file 里面先写上,ENV http_proxy http://proxyhost:proxyport。最后在把
    ENV http_proxy “”
3. Docker build时,指定--build-arg flag。
$ docker build --build-arg HTTP_PROXY=http://10.20.30.2:1234 .


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值