为 docker build 时设置一个代理

各种难,反正就想办法解决呗。

docker build --build-arg http_proxy=http://ip:port --build-arg https_proxy=http://ip:port -t imagename:version .

好处是不影响镜像本身,虽然你可以把代理写到镜像里

ENV http_proxy 10.239.4.80:913

来源

1 个赞

build 代理只能通过 --build-arg 设置,容器代理在 Docker 17.07 以上会自动设成系统代理,不需要手动设置环境变量。不过我更推荐直接上 TUN/TAP 代理,再也不用操心各个软件的代理问题。

1 个赞