IBM / container-service-getting-started-wt

Other
95 stars 212 forks source link

Lab 1 - RUN npm install hangs #92

Closed PavolTomana closed 4 years ago

PavolTomana commented 5 years ago

Hello, have somebody idea where could be problem. I adjust Dockerfile to find out on which line it hangs. I'm beginner in this linux/docker stuff.

FROM node:9.4.0-alpine
COPY app.js .
COPY package.json .
RUN npm install
RUN apk update
RUN apk upgrade
EXPOSE  8080
CMD node app.js

note: namespace - just for publication purpose

$ docker build --tag registry.eu-gb.bluemix.net/<namespace>/hello-world:1 .
Sending build context to Docker daemon  33.19MB
Step 1/8 : FROM node:9.4.0-alpine
9.4.0-alpine: Pulling from library/node
605ce1bd3f31: Pull complete 
fe58b30348fe: Pull complete 
46ef8987ccbd: Pull complete 
Digest: sha256:9cd67a00ed111285460a83847720132204185e9321ec35dacec0d8b9bf674adf
Status: Downloaded newer image for node:9.4.0-alpine
 ---> b5f94997f35f
Step 2/8 : COPY app.js .
 ---> 6e0d0af2f0fb
Step 3/8 : COPY package.json .
 ---> 037218cd0834
Step 4/8 : RUN npm install
 ---> Running in bae21d265ecf

Thanks!

nfritze commented 5 years ago

Hmm - looks like it's getting stuck on the npm install line, then. docker build will run it on your local system - are you behind any firewalls that might block access to the npm repos?

PavolTomana commented 5 years ago

yes, i am behind firewalls. Is there some way how to test connections to npm repositories ?

nfritze commented 5 years ago

add --verbose to the npm install command - that should have it spit out all the connections it's trying to make (and presumably failing on).

alternately, assuming you have the ibmcloud cli installed with the container-registry plugin, you can build it directly in our registry (skip the local copy) using something like ibmcloud cr build --tag registry.eu-gb.bluemix.net/<namespace>/hello-world:1 . instead

PavolTomana commented 5 years ago

I'm not able to "debug" npm install even with --verbose, no output it is just stucked, and also there stay running process with high cpu consumption, which has to be killed manually. But i'm able to build image directly in ibmcloud container registry. Thanks a lot!

Dyktus commented 5 years ago

I would like to add that I had the same problem when building docker images with gitlab CI and gitlab runner. Might it be because we use .npmrc ?

Removing intermediate container 00908dc0e5b7
 ---> 9f9991dcf84c
Step 9/41 : COPY  package.json ./
 ---> a87c9c6ce6c3
Step 10/41 : COPY  package-lock.json ./
 ---> 0503e118aaf1
Step 11/41 : COPY  .npmrc ./
 ---> 75503f310cb2
Step 12/41 : RUN npm install
 ---> Running in 9b19d5d3cc09
jgarcows commented 5 years ago

@Dyktus it is quite possible the .npmrc is the cause, hard to know without knowing what is in the .npmrc file.

Using the container-registry plugin to build in the cloud is definitely a good option when dealing with a strange local environment

potatoronin commented 5 years ago
$ docker build --tag us.icr.io/test/hello-world .
Sending build context to Docker daemon  14.85kB
Step 1/6 : FROM node:9.4.0-alpine
 ---> b5f94997f35f
Step 2/6 : COPY app.js .
 ---> Using cache
 ---> 70649a5d21a9
Step 3/6 : COPY package.json .
 ---> Using cache
 ---> bcaae59ee3c2
Step 4/6 : RUN npm install &&    apk update &&    apk upgrade
 ---> Running in 6e86a37b03f6
npm WARN tar ENOENT: no such file or directory, open '/node_modules/.staging/unpipe-962f02c0/package.json'
npm WARN tar ENOENT: no such file or directory, open '/node_modules/.staging/unpipe-962f02c0/README.md'                            
npm WARN tar ENOENT: no such file or directory, open '/node_modules/.staging/finalhandler-4fdafa9f/package.json'                   
npm WARN tar ENOENT: no such file or directory, open '/node_modules/.staging/unpipe-962f02c0/LICENSE'                              
npm WARN tar ENOENT: no such file or directory, open '/node_modules/.staging/finalhandler-4fdafa9f/HISTORY.md'                     
npm WARN tar ENOENT: no such file or directory, open '/node_modules/.staging/unpipe-962f02c0/index.js'                             
npm WARN tar ENOENT: no such file or directory, open '/node_modules/.staging/finalhandler-4fdafa9f/index.js'                       
npm WARN tar ENOENT: no such file or directory, open '/node_modules/.staging/unpipe-962f02c0/HISTORY.md'                           
npm WARN tar ENOENT: no such file or directory, open '/node_modules/.staging/finalhandler-4fdafa9f/LICENSE'                        
npm WARN tar ENOENT: no such file or directory, open '/node_modules/.staging/finalhandler-4fdafa9f/README.md'                      
npm WARN tar ENOENT: no such file or directory, open '/node_modules/.staging/mime-db-d8839dfc/HISTORY.md'                          
npm WARN tar ENOENT: no such file or directory, open '/node_modules/.staging/mime-db-d8839dfc/index.js'                            
npm WARN tar ENOENT: no such file or directory, open '/node_modules/.staging/mime-db-d8839dfc/LICENSE'                             
npm WARN tar ENOENT: no such file or directory, open '/node_modules/.staging/mime-db-d8839dfc/README.md'                           
npm WARN hello-world-demo@0.0.1 No repository field.                                                                               
npm WARN hello-world-demo@0.0.1 No license field.                                                                                  

npm ERR! code EAI_AGAIN                                                                                                            
npm ERR! errno EAI_AGAIN                                                                                                           
npm ERR! request to https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org:443                                                                                                                         

npm ERR! A complete log of this run can be found in:                                                                               
npm ERR!     /root/.npm/_logs/2019-10-24T08_39_30_892Z-debug.log                                                                   
The command '/bin/sh -c npm install &&    apk update &&    apk upgrade' returned a non-zero code: 1 

Is it like dependencies are missing some files? the Lab tried - 24th of October 2019

jpapejr commented 5 years ago

npm ERR! request to https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org:443

Doesn’t seem like your machine could reach the npm site. Could be a transient error or you you have something blocking your connection there.

potatoronin commented 5 years ago

true, seems to be docker/network issue, following this one - gets resolved https://github.com/moby/moby/issues/32106#issuecomment-382228854

Sorry, for bothering guys.