Docker: npm install behind proxy

前端 未结 5 1775
粉色の甜心
粉色の甜心 2021-02-04 05:56

I have this Dockerfile:

FROM node:argon

ENV http_proxy http://user:pass@proxy.company.priv:3128
ENV https_proxy https://user:pass@proxy.company.priv:3128

RUN m         


        
5条回答
  •  南旧
    南旧 (楼主)
    2021-02-04 06:12

    First the https_proxy should use an http url, not an https url.

    Second, you don't need to embed your proxy settings in your Dockfile: you can use build time variables

    docker build --build-arg HTTP_PROXY=http://user:pass@proxy.company.priv:3128 --build-arg HTTPS_PROXY=http://user:pass@proxy.company.priv:3128 .

    Finally, proxy settings at the docker service level allows the docker daemon to pull images from internet. It does not mean the unix command executed (RUN directive) by docker build would benefit from them. Hence the need to pass them as build-time environment variables.

提交回复
热议问题