NPM install fails inside Docker container but runs on host w/ corporate proxy

时间:2016-02-12 20:13:07

标签: node.js proxy docker npm npm-install

I am deploying some node.js services to a corporate system within docker containers. My Dockerfiles for these services are very basic, with the exception that I am setting the proxy environment variables:

FROM node:4.2.3

ADD . /src

WORKDIR /src

ENV http_proxy http://proxy.gc.corp.com:8888/  
ENV https_proxy http://proxy.gc.corp.com:8888/  
ENV HTTP_PROXY http://proxy.gc.corp.com:8888/  
ENV HTTPS_PROXY http://proxy.gc.corp.com:8888/  


RUN npm install --production

EXPOSE 3000

CMD npm start >> /log/eva_web_api

When I build my image from this file I receive the following error from NPM:

error on last attempt: Error: tunneling socket could not be established, cause=getaddrinfo ENOTFOUND proxy.gc.corp.com proxy.gc.corp.com:8888

However when I perform the NPM install on the host machine (which has Node.js installed as well as Docker), the NPM install performs as normally and completes with no issue. One the host I have those same ENV variables set as I define in my Dockerfile.

Anyone have any ideas as to what is going on here, I have a ticket open with my networking team in charge of the proxy but they are yet to be any help.

1 个答案:

答案 0 :(得分:0)

与DNS相关的是我的解决方案:

Docker - Network calls fail during image build on corporate network

TLDR;必须使用我的DNS IP配置DOCKER_OPTS。