Build problem (network)

I want to use docker with nodeJS but the RUN npm install is not working. I think the problem is th proxy but i did everything i found to fix his. I’m working with virtualbox on windows with ubuntu 64bits inside the VB. I’m in a corporate netwok using a proxy but everything else is working great (image pull for example).

I’m using the following Dockerfile.

FROM node:carbon
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 8080
CMD [ "npm", "start" ]

I try to set the proxy everywhere i can

/etc/default/docker
~/.docker/config.json
/etc/systemd/system/docker.service.d/http-proxy.conf

I also tried to add ENV http_proxy "http://192.168.33.10:3128" in the Dockerfile, I changed the /etc/docker/daemon.json file to add the dns.

But the build is blocked at the npm install line. But npm is not the problem I have the same problem for the docker first app tutoria with the following line

RUN apk add --update py2-pip

The resul is :

fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.5/main: operation timed out

Here is the build result of Dockerfile I use to build the nodeJs project

docker build -t username/node-web-app .
Sending build context to Docker daemon  18.94kB
Step 1/7 : FROM node:carbon
 ---> 41a1f5b81103
Step 2/7 : WORKDIR /usr/src/app
 ---> Using cache
 ---> 9314ce024f57
Step 3/7 : COPY package*.json ./
 ---> Using cache
 ---> f9d648f49710
Step 4/7 : RUN npm install --only=production
 ---> Running in dfadeeca22cc

I have no idea what to do. Thank you for your help

I fixed the problem with RUN apk add --update py2-pip by adding--build-arg HTTP_PROXY=http://proxy in the build command.

But the npm install doesn’t work even if I add the --build-arg.

UPDATE : I made it work by adding the following command before the npm install

RUN npm config set proxy "http://proxy"

The --build-arg command was really a turnover to solve the problem