0

Before you mark my question duplicate ..I tried the everything else I could find on google

STORY: We are using a npm Enterprise private Repo. Docker + Vagrant are used for build Env Setup. Setup scripts contain npm installs referencing packages from private repo. And npm installs are failing with below error

npm http request GET https://npm.lab.myorg.com/passport-http
npm info attempt registry request try #3 at 4:27:26 PM
npm http request GET https://npm.lab.myorg.com/verror
npm ERR! Linux 3.13.0-24-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v5.6.0
npm ERR! npm  v3.6.0
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! syscall getaddrinfo

npm ERR! network getaddrinfo ENOTFOUND npm.lab.myorg.com npm.lab.myorg.com:443
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is 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! Please include the following file with any support request:
npm ERR!     /usr/src/app/npm-debug.log

I have tried everything suggested on web

  1. Tried restarting dns.
  2. Found out from IT dept if there is any proxy and there is none. So made sure npm config proxy is empty
  3. I checked connectivity to npm.lab.myorg.com:443 and its good

    vagrant@dockerhost:~/git/ curl -Is https://npm.lab.myorg.com/ HTTP/1.1 200 OK Server: nginx/1.4.6 (Ubuntu) Date: Sun, 16 Oct 2016 16:26:40 GMT Content-Type: text/html; charset=utf-8 Content-Length: 36342 Connection: keep-alive X-Powered-By: Sinopia/1.4.0 X-Frame-Options: deny ETag: "180fec4dfa875dd07ebf5f43887ca234" Vary: Accept-Encoding X-Status-Cat: http://flic.kr/p/aVuVsF

UPDATE 1; Curl from inside docker container is failing when inserted the step RUN curl -I -vvvv https://npm.lab.myorg.com/ in Dockerfile

This is the output

Step 5 : RUN curl -I -vvvv https://npm.lab.myorg.com/
 ---> Running in a677c4429ea5
* Hostname was NOT found in DNS cache
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Could not resolve host: npm.lab.myorg.com
* Closing connection 0
curl: (6) Could not resolve host: npm.lab.myorg.com
ERROR: Service '******' failed to build: The command '/bin/sh -c curl -I -vvvv https://npm.lab.myorg.com/' returned a non-zero code: 6

The same curl when running from terminal is working all good.

UPDATE 2: The docker file contents below

FROM tools.lab.myorg.com:5000/myorg/node:0.10.40.3
LABEL description="blahhblah API" \
    version=1.0
ENV WORKDIR=/usr/src/app
WORKDIR $WORKDIR
RUN curl -I -vvvv https://www.google.co.in/
RUN mkdir -p $WORKDIR/script \
    && npm install -g privatePackage1
    && npm install -g privatePackage2
# COPY ./package.json $WORKDIR
# COPY ./script/ $WORKDIR/script/
# RUN ./script/bootstrap
COPY . $WORKDIR
CMD ["script/server"]
AdityaReddy
  • 3,625
  • 12
  • 25

1 Answers1

1

Try running curl -I -vvvv https://npm.lab.myorg.com/ directly before your npm install command inside your setup scripts (which I presume are being run on the Docker container from a Dockerfile RUN command?).

This should print out some debug information to show you whether the Docker container can access your private repo at all.

ocean
  • 1,335
  • 15
  • 26
  • I guess you were spot on in identifying the problem. `Curl` from inside docker container is indeed failing.whereas `curl` outside from terminal is successfull .. I have updated the answer with curl verbose output .. Do you have any solution for why this is happening only from inside docker container – AdityaReddy Oct 17 '16 at 05:08
  • Narrowing things down always helps :) Can the container `curl` any other URLs? – ocean Oct 17 '16 at 05:20
  • Also, which Docker container are you using? A custom one, or one from the Docker Hub? Can you post your Dockerfile contents (or some of it) ? – ocean Oct 17 '16 at 05:21
  • yes @ocean .. I am able to `curl -I -vvvv https://www.google.co.in/` And regarding the docker container we are creating a custom one using DockerFile I have updated the question with some contents – AdityaReddy Oct 17 '16 at 05:32
  • Take a look at the top answer on this s.o question http://stackoverflow.com/questions/24151129/docker-network-calls-fail-during-image-build-on-corporate-network If your Docker container is based on Ubuntu (and maybe others), it's trying to use Google DNS, which may not be accessible from where you are. Maybe that's the issue? – ocean Oct 17 '16 at 05:38