npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.33k stars 3.06k forks source link

when build docker got : if you are behind a proxy, please make sure that the 'proxy' config is set properly. #4219

Closed shakori999 closed 2 years ago

shakori999 commented 2 years ago

Is there an existing issue for this?

This issue exists in the latest npm version

Current Behavior

I want to build a docker-compose for a taxi-app project I'm working on. and just to be clear I can install any package normally with npm i [any package] when i run docker-compose up -d --build

Building 52.9s (22/23)
 => [taxi-app_taxi-server internal] load build definition from Dockerfile                                              0.0s 
 => => transferring dockerfile: 359B                                                                                   0.0s 
 => [taxi-app_taxi-server internal] load .dockerignore                                                                 0.0s 
 => => transferring context: 86B                                                                                       0.0s 
 => [taxi-app_taxi-client internal] load build definition from Dockerfile                                              0.0s 
 => => transferring dockerfile: 468B                                                                                   0.0s 
 => [taxi-app_taxi-client internal] load .dockerignore                                                                 0.0s 
 => => transferring context: 119B                                                                                      0.0s 
 => [taxi-app_taxi-server internal] load metadata for docker.io/library/python:3.7.5-alpine                            2.5s 
 => [taxi-app_taxi-client internal] load metadata for docker.io/library/node:16.13.1-alpine                            2.4s 
 => [taxi-app_taxi-client 1/7] FROM docker.io/library/node:16.13.1-alpine@sha256:0e071f3c5c84cffa6b1035023e1956cf28d4  0.0s 
 => [taxi-app_taxi-client internal] load build context                                                                 0.0s 
 => => transferring context: 1.20kB                                                                                    0.0s 
 => [taxi-app_taxi-server internal] load build context                                                                 0.0s 
 => => transferring context: 6.31kB                                                                                    0.0s 
 => [taxi-app_taxi-server 1/7] FROM docker.io/library/python:3.7.5-alpine@sha256:de9fc5bc46cb1a7e2222b976394ea8aa0290  0.0s 
 => CACHED [taxi-app_taxi-client 2/7] RUN mkdir -p /usr/src/app                                                        0.0s 
 => CACHED [taxi-app_taxi-client 3/7] WORKDIR /usr/src/app                                                             0.0s 
 => CACHED [taxi-app_taxi-client 4/7] COPY package.json /usr/src/app/package.json                                      0.0s 
 => CACHED [taxi-app_taxi-client 5/7] COPY package-lock.json /usr/src/app/package-lock.json                            0.0s 
 => ERROR [taxi-app_taxi-client 6/7] RUN npm install --production                                                     50.2s 
 => CACHED [taxi-app_taxi-server 2/7] RUN apk update && apk add build-base python-dev py-pip jpeg-dev zlib-dev openss  0.0s 
 => CACHED [taxi-app_taxi-server 3/7] WORKDIR /usr/src/app                                                             0.0s 
 => CACHED [taxi-app_taxi-server 4/7] COPY ./requirements.txt /usr/src/app                                             0.0s 
 => CACHED [taxi-app_taxi-server 5/7] RUN pip install --upgrade pip                                                    0.0s 
 => CACHED [taxi-app_taxi-server 6/7] RUN pip install -r requirements.txt                                              0.0s 
 => CACHED [taxi-app_taxi-server 7/7] COPY . /usr/src/app                                                              0.0s 
 => [taxi-app_taxi-server] exporting to image                                                                          0.0s 
 => => exporting layers                                                                                                0.0s 
 => => writing image sha256:8e2a1a48d84a0735199a7e2b0cfe562cbcfa5392b595f63023b023ad311cda23                           0.0s 
 => => naming to docker.io/library/taxi-app_taxi-server                                                                0.0s 
------
 > [taxi-app_taxi-client 6/7] RUN npm install --production:
#13 50.06 npm notice
#13 50.06 npm notice New minor version of npm available! 8.1.2 -> 8.3.0
#13 50.06 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.3.0>
#13 50.06 npm notice Run `npm install -g npm@8.3.0` to update!
#13 50.06 npm notice
#13 50.06 npm ERR! code ERR_SOCKET_TIMEOUT
#13 50.07 npm ERR! network Socket timeout
#13 50.07 npm ERR! network This is a problem related to network connectivity.
#13 50.07 npm ERR! network In most cases you are behind a proxy or have bad network settings.
#13 50.07 npm ERR! network
#13 50.07 npm ERR! network If you are behind a proxy, please make sure that the
#13 50.07 npm ERR! network 'proxy' config is set properly.  See: 'npm help config'
#13 50.10
#13 50.10 npm ERR! A complete log of this run can be found in:
#13 50.10 npm ERR!     /root/.npm/_logs/2022-01-07T14_03_29_522Z-debug.log
------
failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c npm install --production]: exit code: 
1

Expected Behavior

built the docker container without any problem,

Steps To Reproduce

  1. clone this repro https://github.com/shakori999/taxi-app.git
  2. Run docker-compose up -d --build
  3. See error...
    Building 52.9s (22/23)
    => [taxi-app_taxi-server internal] load build definition from Dockerfile                                              0.0s 
    => => transferring dockerfile: 359B                                                                                   0.0s 
    => [taxi-app_taxi-server internal] load .dockerignore                                                                 0.0s 
    => => transferring context: 86B                                                                                       0.0s 
    => [taxi-app_taxi-client internal] load build definition from Dockerfile                                              0.0s 
    => => transferring dockerfile: 468B                                                                                   0.0s 
    => [taxi-app_taxi-client internal] load .dockerignore                                                                 0.0s 
    => => transferring context: 119B                                                                                      0.0s 
    => [taxi-app_taxi-server internal] load metadata for docker.io/library/python:3.7.5-alpine                            2.5s 
    => [taxi-app_taxi-client internal] load metadata for docker.io/library/node:16.13.1-alpine                            2.4s 
    => [taxi-app_taxi-client 1/7] FROM docker.io/library/node:16.13.1-alpine@sha256:0e071f3c5c84cffa6b1035023e1956cf28d4  0.0s 
    => [taxi-app_taxi-client internal] load build context                                                                 0.0s 
    => => transferring context: 1.20kB                                                                                    0.0s 
    => [taxi-app_taxi-server internal] load build context                                                                 0.0s 
    => => transferring context: 6.31kB                                                                                    0.0s 
    => [taxi-app_taxi-server 1/7] FROM docker.io/library/python:3.7.5-alpine@sha256:de9fc5bc46cb1a7e2222b976394ea8aa0290  0.0s 
    => CACHED [taxi-app_taxi-client 2/7] RUN mkdir -p /usr/src/app                                                        0.0s 
    => CACHED [taxi-app_taxi-client 3/7] WORKDIR /usr/src/app                                                             0.0s 
    => CACHED [taxi-app_taxi-client 4/7] COPY package.json /usr/src/app/package.json                                      0.0s 
    => CACHED [taxi-app_taxi-client 5/7] COPY package-lock.json /usr/src/app/package-lock.json                            0.0s 
    => ERROR [taxi-app_taxi-client 6/7] RUN npm install --production                                                     50.2s 
    => CACHED [taxi-app_taxi-server 2/7] RUN apk update && apk add build-base python-dev py-pip jpeg-dev zlib-dev openss  0.0s 
    => CACHED [taxi-app_taxi-server 3/7] WORKDIR /usr/src/app                                                             0.0s 
    => CACHED [taxi-app_taxi-server 4/7] COPY ./requirements.txt /usr/src/app                                             0.0s 
    => CACHED [taxi-app_taxi-server 5/7] RUN pip install --upgrade pip                                                    0.0s 
    => CACHED [taxi-app_taxi-server 6/7] RUN pip install -r requirements.txt                                              0.0s 
    => CACHED [taxi-app_taxi-server 7/7] COPY . /usr/src/app                                                              0.0s 
    => [taxi-app_taxi-server] exporting to image                                                                          0.0s 
    => => exporting layers                                                                                                0.0s 
    => => writing image sha256:8e2a1a48d84a0735199a7e2b0cfe562cbcfa5392b595f63023b023ad311cda23                           0.0s 
    => => naming to docker.io/library/taxi-app_taxi-server                                                                0.0s 
    ------
    > [taxi-app_taxi-client 6/7] RUN npm install --production:
    #13 50.06 npm notice
    #13 50.06 npm notice New minor version of npm available! 8.1.2 -> 8.3.0
    #13 50.06 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.3.0>
    #13 50.06 npm notice Run `npm install -g npm@8.3.0` to update!
    #13 50.06 npm notice
    #13 50.06 npm ERR! code ERR_SOCKET_TIMEOUT
    #13 50.07 npm ERR! network Socket timeout
    #13 50.07 npm ERR! network This is a problem related to network connectivity.
    #13 50.07 npm ERR! network In most cases you are behind a proxy or have bad network settings.
    #13 50.07 npm ERR! network
    #13 50.07 npm ERR! network If you are behind a proxy, please make sure that the
    #13 50.07 npm ERR! network 'proxy' config is set properly.  See: 'npm help config'
    #13 50.10
    #13 50.10 npm ERR! A complete log of this run can be found in:
    #13 50.10 npm ERR!     /root/.npm/_logs/2022-01-07T14_03_29_522Z-debug.log
    ------
    failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c npm install --production]: exit code: 
    1

Environment

; "builtin" config from C:\Program Files\nodejs\node_modules\npm\npmrc

prefix = "C:\Users\shako\AppData\Roaming\npm"

; "user" config from C:\Users\shako.npmrc

http = "http://localhost:3128" registry = "https://registry.npmjs.org/"

; node bin location = C:\Program Files\nodejs\node.exe ; cwd = C:\Users\shako\Desktop\taxi-app\client ; HOME = C:\Users\shako ; Run npm config ls -l to show all defaults.

kasvith commented 2 years ago

I'm also having this issue

the-vampiire commented 2 years ago

@shakori999 im having the exact same problem. locally installs fine. crashes 9/10 times when building from docker. i see you closed the issue what was your resolution?

mertyildiran commented 2 years ago

Some servers might be blocked in your country or by your ISP. Try using VPN.

K0IN commented 2 years ago

This happens for me in github actions, I can't believe that they are blocked by any ISP. @mertyildiran

mertyildiran commented 2 years ago

@K0IN in my case VPN solved the issue on my machine. It could be an address resolution issue as well. I'm not sure about GitHub Actions but I agree that it shouldn't be a blocked IP or domain issue in case of any CI provider. I just recommended trying VPN.

The-macharia commented 8 months ago

If you're coming into this. Attempt building your docker image using the official base image FROM node:14 or latest.