verdaccio / docker-examples

🐳 ⛴A collection of Docker and Kubernetes examples for verdaccio

Home Page:https://www.verdaccio.org/docs/en/docker.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ECONNREFUSED 127.0.0.1:80

GitProdEnv opened this issue · comments

Summary:

I am running the reverse-proxy/nginx example with nginx ssl (https://github.com/verdaccio/docker-examples/tree/master/reverse_proxy/nginx/relative_path) in a development environment.
Publishing is working as expected, but I have a problem when I want to build a new docker image and use npm install within my Dockerfile.

Reproduction:

Running the reverse-proxy/nginx example
docker-compose -f docker-compose_ssl.yml up --build --force-recreate
and
npm publish

Result: I can go to localhost and see my published package. I also can npm install it via the command line.

After that, that's my simple Dockerfile to build:

FROM node:13.3-alpine

WORKDIR /app
COPY package.json .
RUN npm install --only=prod --registry http://localhost
COPY . .

CMD ["npm", "start"]

Error:

npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! FetchError: request to http://localhost/@gitprodenv%2fcommon failed, reason: connect ECONNREFUSED 127.0.0.1:80
npm ERR!     at ClientRequest.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:68:14)
npm ERR!     at ClientRequest.emit (events.js:219:5)
npm ERR!     at Socket.socketErrorListener (_http_client.js:420:9)
npm ERR!     at Socket.emit (events.js:219:5)
npm ERR!     at emitErrorNT (internal/streams/destroy.js:84:8)
npm ERR!     at processTicksAndRejections (internal/process/task_queues.js:84:21)
npm ERR!  FetchError: request to http://localhost/@gitprodenv%2fcommon failed, reason: connect ECONNREFUSED 127.0.0.1:80
npm ERR!     at ClientRequest.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:68:14)
npm ERR!     at ClientRequest.emit (events.js:219:5)
npm ERR!     at Socket.socketErrorListener (_http_client.js:420:9)
npm ERR!     at Socket.emit (events.js:219:5)
npm ERR!     at emitErrorNT (internal/streams/destroy.js:84:8)
npm ERR!     at processTicksAndRejections (internal/process/task_queues.js:84:21) {
npm ERR!   message: 'request to http://localhost/@gitprodenv%2fcommon failed, reason: connect ECONNREFUSED 127.0.0.1:80',
npm ERR!   type: 'system',
npm ERR!   errno: 'ECONNREFUSED',
npm ERR!   code: 'ECONNREFUSED',
npm ERR!   stack: 'FetchError: request to http://localhost/@gitprodenv%2fcommon failed, reason: connect ECONNREFUSED 127.0.0.1:80\n' +
npm ERR!     '    at ClientRequest.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:68:14)\n' +
npm ERR!     '    at ClientRequest.emit (events.js:219:5)\n' +
npm ERR!     '    at Socket.socketErrorListener (_http_client.js:420:9)\n' +
npm ERR!     '    at Socket.emit (events.js:219:5)\n' +
npm ERR!     '    at emitErrorNT (internal/streams/destroy.js:84:8)\n' +
npm ERR!     '    at processTicksAndRejections (internal/process/task_queues.js:84:21)',
npm ERR!   parent: 'app'
npm ERR! }
npm ERR! 
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! 'proxy' config is set properly.  See: 'npm help config'

I am already spending days because of that problem. I want to use verdaccio as a proxy for building new docker images. Thanks for your help.

I solved it with prepending docker build with --network="host"