Estou criando um arquivo docker-compose
para subir um sistema com vários nós. Para começar a testar, criei apenas um serviço nesse arquivo 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
Para construir o meu serviço, tenho o Dockerfile abaixo:
FROM node:latest
MAINTAINER Douglas Quintanilha
ENV NODE_ENV=development
COPY . /var/www
WORKDIR /var/www
RUN npm install
ENTRYPOINT ["npm", "start"]
EXPOSE 3000
Como utilizo um proxy coorporativo, pesquisei a forma de informá-lo para o build dessa imagem, e verifiquei que isso seria possível com o npm config
. Então, adicionei os comandos:
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
é o ip da minha máquina que serve de proxy na porta 3128
, sem autenticação requerida. O problema é que quando tento rodar o build, ocorre erro devido a essa configuração de proxy:
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
Como eu deveria configurar o proxy para o build dessa imagem no docker-compose
? Já procurei em vários tutoriais, mas não obtive sucesso.
OBS: - Máquina: Ubuntu 18 - Docker version 18.06.1-ce - docker-compose version 1.15.0, build e12f3b9
ENV HTTP_PROXY "http://127.0.0.1:3001"
funcione.