Reputation: 7083
I'm having a hard problem getting my Docker container up, it shows some weird error in the console, I have zero clues about it as I'm a newbie:
Dockerfile:
FROM node:14
WORKDIR /usr/src/app/
COPY package.json package.json
COPY server.js server.js
RUN ping -c 4 google.com
RUN npm config set registry https://registry.npmjs.com/
RUN echo "${http_proxy}" && echo "${HTTP_PROXY}"
RUN npm install
# COPY . .
EXPOSE 3000
CMD ['npm', 'start']
When I run the docker build command
$ docker build -t myapp .
The error I'm getting:
Sending build context to Docker daemon 947.7kB
Step 1/7 : FROM node:14
---> 7bef16bb2cf1
Step 2/7 : WORKDIR /usr/src/app/
---> Using cache
---> 90402606c386
Step 3/7 : COPY package.json ./
---> Using cache
---> b839b81ee876
Step 4/7 : RUN npm install
---> Running in 64378581f715
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! FetchError: request to https://registry.npmjs.org/@slack%2fevents-api failed, reason: connect ECONNREFUSED 104.16.18.35:443
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:315:20)
npm ERR! at TLSSocket.socketErrorListener (_http_client.js:469:9)
npm ERR! at TLSSocket.emit (events.js:315:20)
npm ERR! at emitErrorNT (internal/streams/destroy.js:106:8)
npm ERR! at emitErrorCloseNT (internal/streams/destroy.js:74:3)
npm ERR! at processTicksAndRejections (internal/process/task_queues.js:80:21)
npm ERR! FetchError: request to https://registry.npmjs.org/@slack%2fevents-api failed, reason: connect ECONNREFUSED 104.16.18.35:443
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:315:20)
npm ERR! at TLSSocket.socketErrorListener (_http_client.js:469:9)
npm ERR! at TLSSocket.emit (events.js:315:20)
npm ERR! at emitErrorNT (internal/streams/destroy.js:106:8)
npm ERR! at emitErrorCloseNT (internal/streams/destroy.js:74:3)
npm ERR! at processTicksAndRejections (internal/process/task_queues.js:80:21) {
npm ERR! type: 'system',
npm ERR! errno: 'ECONNREFUSED',
npm ERR! code: 'ECONNREFUSED'
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'
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-03-02T08_20_08_546Z-debug.log
The command '/bin/sh -c npm install' returned a non-zero code: 1
I'm on Ubuntu 20.4 and it is just a simple node app with a server.js file. let me know if you need anything else from me to get it fixed. Thank you in advance for your help!
https://i.sstatic.net/Nl7g1.png
Upvotes: 1
Views: 3404
Reputation: 7083
It seems something is wrong with either the docker network, proxy, or firewall. it can be fixed by specifying the --network="host"
$ docker build -t myapp . --network="host"
boom it started working like charm!
Upvotes: 6