2
I’m creating a file docker-compose
to upload a system with multiple nodes. To start testing, I created only one service in that file docker-compose.yml
:
version: '3'
networks:
production-network:
driver: bridge
services:
node1:
build:
dockerfile: ./docker/alura-books.dockerfile
context: .
image: giulianasilvabezerra/alura-books
container_name: alura-books-1
ports:
- "3000"
networks:
- production-network
To build my service, I have the Dockerfile below:
FROM node:latest
MAINTAINER Douglas Quintanilha
ENV NODE_ENV=development
COPY . /var/www
WORKDIR /var/www
RUN npm install
ENTRYPOINT ["npm", "start"]
EXPOSE 3000
Since I use a corporate proxy, I researched how to inform you to build this image, and verified that this would be possible with the npm config
. So I added the commands:
RUN npm cache clean -f
RUN npm config set proxy http://10.100.5.107:3128
RUN npm config set https-proxy http://10.100.5.107:3128
RUN npm update
RUN npm install
Ond 10.100.5.107
is the ip of my machine that serves as a proxy on the port 3128
, no authentication required. The problem is that when I try to run the build, an error occurs due to this proxy setting:
docker-compose build
Building node1
Step 1/12 : FROM node:latest ---> 8672b25e842c
Step 2/12 : MAINTAINER Douglas Quintanilha ---> Using cache
---> 57cc55c8c60a
Step 3/12 : ENV NODE_ENV=development
---> Using cache
---> ad9c7e8d30c1
Step 4/12 : COPY . /var/www
---> aec64fdc16ae
Step 5/12 : WORKDIR /var/www
---> Running in d1121964dbe4
Removing intermediate container d1121964dbe4
---> 78f225a89e7d
Step 6/12 : RUN npm cache clean -f
---> Running in f84cd3c05903
npm WARN using --force I sure hope you know what you are doing.
Removing intermediate container f84cd3c05903
---> ec8d4392504e
Step 7/12 : RUN npm config set proxy http://localhost:3128
---> Running in 1d9af892155c
Removing intermediate container 1d9af892155c
---> 71813002714c
Step 8/12 : RUN npm config set https-proxy http://localhost:3128
---> Running in 3d9376ff8574
Removing intermediate container 3d9376ff8574 ---> a74660004639
Step 9/12 : RUN npm update
---> Running in 1af0de20e9e2
npm ERR! code ECONNRESET
npm ERR! network tunneling socket could not be established, cause=connect ECONNREFUSED 127.0
.0.1:3128
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-10-01T15_32_58_226Z-debug.log
ERROR: Service 'node1' failed to build: The command '/bin/sh -c npm update' returned a non-z
ero code: 1
How should I set up the proxy to build this image on docker-compose
? I have searched in several tutorials, but I did not succeed.
OBS: - Machine: Ubuntu 18 - Docker version 18.06.1-ce - Docker-Compose version 1.15.0, build e12f3b9
Hello, take a look at this link, maybe the option to set as an environment variable
ENV HTTP_PROXY "http://127.0.0.1:3001"
work.– MSLacerda
I have tried this, but only the environment variable is not enough to configure NPM. When I set it up also with npm config keeps giving connection error. Although, when I drop to proxy address it works.
– Giuliana Bezerra