I am creating a docker-compose
file to upload a multi-node system. To start testing, I created only one service in this 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 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
As I use a corporate proxy, I researched how to tell you how to build this image, and I checked that this would be possible with 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 proxy on the 3128
port, without authentication required. The problem is that when I try to run the build, an error occurs because of this proxy configuration:
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 configure the proxy for the build of this image in docker-compose
? I've tried several tutorials, but I did not succeed.
- Machine: Ubuntu 18 - Docker version 18.06.1-ce - docker-compose version 1.15.0, build e12f3b9