getting-started: ERROR: failed to solve: process "/bin/sh -c yarn install --production" did not complete successfully: exit code: 1

Hi, I have an issue, with basically the same effect as #347 but probably a different resolution

docker build from getting-started

I’m on the tutorial, same step as 347 I try to build the image via docker build -t getting-started . And I end up with:

=> [3/4] COPY . .                                                                                                                                                           0.0s
 => ERROR [4/4] RUN yarn install --production                                                                                                                                0.8s
------                                                                                                                                                                            
 > [4/4] RUN yarn install --production:                                                                                                                                           
#0 0.570 yarn install v1.22.19                                                                                                                                                    
#0 0.599 info No lockfile found.
#0 0.612 [1/4] Resolving packages...
#0 0.714 error An unexpected error occurred: "https://registry.yarnpkg.com/ansi-regex: getaddrinfo EACCES registry.yarnpkg.com".
#0 0.714 info If you think this is a bug, please open a bug report with the information provided in "/app/yarn-error.log".
#0 0.714 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
------
Dockerfile:6
--------------------
   4 |     WORKDIR /app
   5 |     COPY . .
   6 | >>> RUN yarn install --production
   7 |     CMD ["node", "src/index.js"]
   8 |     EXPOSE 3000
--------------------
ERROR: failed to solve: process "/bin/sh -c yarn install --production" did not complete successfully: exit code: 1

docker compose up

Just to try a different build, If I run docker compose up from getting-started/ I get :

WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7ffa4ff71650>: Failed to establish a new connection: [Errno 13] Permission denied')': /simple/mkdocs/
#0 10.11 ERROR: Could not find a version that satisfies the requirement mkdocs==1.3.0 (from versions: none)
#0 10.11 ERROR: No matching distribution found for mkdocs==1.3.0
#0 10.12 WARNING: There was an error checking the latest version of pip.
------
failed to solve: process "/bin/sh -c pip install -r requirements.txt" did not complete successfully: exit code: 1

nslookup registry.yarnpkg.com

And finally if I test the connectivity

docker run busybox nslookup registry.yarnpkg.com
nslookup: socket: Permission denied

Clean try

I also tried to clone the repo again and start from scratch and it’s the same. It’s an issue from my system. I did reboot too.

I’m on Ubuntu 20.04 Would someone have something to recommend to solve this please ?

About this issue

Most upvoted comments

Try RUN yarn install --production –ignore-engines in Docker file

I have basically same problem. I’m sorry, but docker came strongly recommended for something I’m trying to do. I can’t make it past the tutorial. Frown.

did you checked the version of metadata? now, I’m following docker tutorial, and have a same issues.

this is default example which i’ve problem.

FROM node:12-alpine
RUN apk add --no-cache python2 g++ make
WORKDIR /app
COPY . .
RUN yarn install --production
CMD ["node", "/app/src/index.js"]

but i checked the version of nodeJS and python, at the CMD.

FROM node:14-alpine
RUN apk add --no-cache python3 g++ make
WORKDIR /app
COPY . .
RUN yarn install --production
CMD ["node", "/app/src/index.js"]

i’m on ubuntu 11.1.0v but I reckon you can solve a problem.

hello guys,I think today I figure out this problem in my case.So I’m here to share my solution.

My development environment:

OS : CentOS Linux release 7.5.1804 Docker Version : 25.0.0

Solution process:

  1. I running command docker build -t getting-started .. then I got those
[+] Building 42.3s (10/10) FINISHED                                                     docker:default
 => [internal] load build definition from Dockerfile                                              0.0s
 => => transferring dockerfile: 185B                                                              0.0s
 => resolve image config for docker.io/docker/dockerfile:1                                        4.6s
 => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:ac85f380a63b13dfcefa89046420e1781  0.0s
 => [internal] load metadata for docker.io/library/node:18-alpine                                 8.0s
 => [internal] load .dockerignore                                                                 0.0s
 => => transferring context: 2B                                                                   0.0s
 => [1/4] FROM docker.io/library/node:18-alpine@sha256:b1a0356f7d6b86c958a06949d3db3f7fb27f95f62  0.0s
 => [internal] load build context                                                                 0.0s
 => => transferring context: 4.33kB                                                               0.0s
 => CACHED [2/4] WORKDIR /app                                                                     0.0s
 => CACHED [3/4] COPY . .                                                                         0.0s
 => ERROR [4/4] RUN yarn install --ignore-engines                                                29.2s
------                                                                                                 
 > [4/4] RUN yarn install --ignore-engines:                                                            
1.191 yarn install v1.22.19                                                                            
1.454 [1/4] Resolving packages...                                                                      
2.084 [2/4] Fetching packages...                                                                       
23.69 error An unexpected error occurred: "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.1.tgz: connect ECONNREFUSED 104.16.2.35:443".
23.69 info If you think this is a bug, please open a bug report with the information provided in "/app/yarn-error.log".
23.69 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
------
Dockerfile:6
--------------------
   4 |     WORKDIR /app
   5 |     COPY . .
   6 | >>> RUN yarn install --ignore-engines
   7 |     CMD ["node","src/index.js"]
   8 |     EXPOSE 3000
--------------------
ERROR: failed to solve: process "/bin/sh -c yarn install --ignore-engines" did not complete successfully: exit code: 1

Looking at the logs above,I realized I had network issues during the build process.

  1. I change the original Dockerfile like this: The command yarn config set registry http://registry.npmmirror.com has url http://registry.npmmirror.com ,which is a mirror site that provided by Alibaba open source mirror site
# syntax=docker/dockerfile:1

FROM node:18-alpine
WORKDIR /app
COPY . .
RUN yarn config set registry http://registry.npmmirror.com
RUN yarn install --ignore-engines
CMD ["node","src/index.js"]
EXPOSE 3000

and I running the command docker build -t getting-started . again.Then I got those:

[+] Building 40.8s (11/11) FINISHED                                                     docker:default
 => [internal] load build definition from Dockerfile                                              0.0s
 => => transferring dockerfile: 244B                                                              0.0s
 => resolve image config for docker.io/docker/dockerfile:1                                        5.7s
 => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:ac85f380a63b13dfcefa89046420e1781  0.0s
 => [internal] load metadata for docker.io/library/node:18-alpine                                 5.6s
 => [internal] load .dockerignore                                                                 0.0s
 => => transferring context: 2B                                                                   0.0s
 => [1/5] FROM docker.io/library/node:18-alpine@sha256:b1a0356f7d6b86c958a06949d3db3f7fb27f95f62  0.0s
 => [internal] load build context                                                                 0.0s
 => => transferring context: 4.55kB                                                               0.0s
 => CACHED [2/5] WORKDIR /app                                                                     0.0s
 => [3/5] COPY . .                                                                                0.1s
 => [4/5] RUN yarn config set registry http://registry.npmmirror.com                              0.7s
 => ERROR [5/5] RUN yarn install --ignore-engines                                                28.4s
------                                                                                                 
 > [5/5] RUN yarn install --ignore-engines:                                                            
0.515 yarn install v1.22.19                                                                            
0.651 [1/4] Resolving packages...                                                                      
1.139 [2/4] Fetching packages...                                                                       
22.56 error An unexpected error occurred: "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz: connect ECONNREFUSED 104.16.0.35:443".
22.56 info If you think this is a bug, please open a bug report with the information provided in "/app/yarn-error.log".
22.56 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
------
Dockerfile:7
--------------------
   5 |     COPY . .
   6 |     RUN yarn config set registry http://registry.npmmirror.com
   7 | >>> RUN yarn install --ignore-engines
   8 |     CMD ["node","src/index.js"]
   9 |     EXPOSE 3000
--------------------
ERROR: failed to solve: process "/bin/sh -c yarn install --ignore-engines" did not complete successfully: exit code: 1

Look at the logs,It’s still use the same url:https://registry.yarnpkg.com/.And I realized that I didn’t refresh the yarn’s config cache during the build process.

  1. Then I change the original Dockerfile like this: The command yarn cache clean is used to clear yarn cache. The command yarn install --force is used to refetches all packages, even ones that were previously installed.
# syntax=docker/dockerfile:1

FROM node:18-alpine
WORKDIR /app
COPY . .
RUN yarn config set registry http://registry.npmmirror.com
RUN yarn cache clean
RUN yarn install --production --force
CMD ["node","src/index.js"]
EXPOSE 3000
  1. Then I run command docker build -t getting-started . again.(Note:Please remember to delete yarn.lock in the directory, otherwise the original URL will still be used ) Then I got those logs:
[+] Building 61.2s (12/12) FINISHED                                                                                                                                                               docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                                        0.0s
 => => transferring dockerfile: 272B                                                                                                                                                                        0.0s
 => resolve image config for docker.io/docker/dockerfile:1                                                                                                                                                  5.1s
 => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:ac85f380a63b13dfcefa89046420e1781752bab202122f8f50032edf31be0021                                                                             0.0s
 => [internal] load metadata for docker.io/library/node:18-alpine                                                                                                                                           5.6s
 => [internal] load .dockerignore                                                                                                                                                                           0.0s
 => => transferring context: 2B                                                                                                                                                                             0.0s
 => [1/6] FROM docker.io/library/node:18-alpine@sha256:b1a0356f7d6b86c958a06949d3db3f7fb27f95f627aa6157cb98bc65c801efa2                                                                                     0.0s
 => [internal] load build context                                                                                                                                                                           0.0s
 => => transferring context: 4.54kB                                                                                                                                                                         0.0s
 => CACHED [2/6] WORKDIR /app                                                                                                                                                                               0.0s
 => [3/6] COPY . .                                                                                                                                                                                          0.0s
 => [4/6] RUN yarn config set registry http://registry.npmmirror.com                                                                                                                                        0.6s
 => [5/6] RUN yarn cache clean                                                                                                                                                                              0.7s 
 => ERROR [6/6] RUN yarn install --production --force                                                                                                                                                      48.9s 
------                                                                                                                                                                                                           
 > [6/6] RUN yarn install --production --force:                                                                                                                                                                  
0.537 yarn install v1.22.19                                                                                                                                                                                      
0.587 info No lockfile found.                                                                                                                                                                                    
0.604 [1/4] Resolving packages...                                                                                                                                                                                
3.946 warning sqlite3 > node-gyp > make-fetch-happen > cacache > @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs                                                                        
8.554 [2/4] Fetching packages...
25.14 [3/4] Linking dependencies...
26.85 [4/4] Rebuilding all packages...
48.77 error /app/node_modules/sqlite3: Command failed.
48.77 Exit code: 1
48.77 Command: prebuild-install -r napi || node-gyp rebuild
48.77 Arguments: 
48.77 Directory: /app/node_modules/sqlite3
48.77 Output:
48.77 prebuild-install warn install connect ECONNREFUSED 20.205.243.166:443
48.77 gyp info it worked if it ends with ok
48.77 gyp info using node-gyp@8.4.1
48.77 gyp info using node@18.19.0 | linux | x64
48.77 gyp ERR! find Python 
48.77 gyp ERR! find Python Python is not set from command line or npm configuration
48.77 gyp ERR! find Python Python is not set from environment variable PYTHON
48.77 gyp ERR! find Python checking if "python3" can be used
48.77 gyp ERR! find Python - "python3" is not in PATH or produced an error
48.77 gyp ERR! find Python checking if "python" can be used
48.77 gyp ERR! find Python - "python" is not in PATH or produced an error
48.77 gyp ERR! find Python 
48.77 gyp ERR! find Python **********************************************************
48.77 gyp ERR! find Python You need to install the latest version of Python.
48.77 gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
48.77 gyp ERR! find Python you can try one of the following options:
48.77 gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
48.77 gyp ERR! find Python   (accepted by both node-gyp and npm)
48.77 gyp ERR! find Python - Set the environment variable PYTHON
48.77 gyp ERR! find Python - Set the npm configuration variable python:
48.77 gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
48.77 gyp ERR! find Python For more information consult the documentation at:
48.77 gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
48.77 gyp ERR! find Python **********************************************************
48.77 gyp ERR! find Python 
48.77 gyp ERR! configure error 
48.77 gyp ERR! stack Error: Could not find any Python installation to use
48.77 gyp ERR! stack     at PythonFinder.fail (/app/node_modules/node-gyp/lib/find-python.js:330:47)
48.77 gyp ERR! stack     at PythonFinder.runChecks (/app/node_modules/node-gyp/lib/find-python.js:159:21)
48.77 gyp ERR! stack     at PythonFinder.<anonymous> (/app/node_modules/node-gyp/lib/find-python.js:202:16)
48.77 gyp ERR! stack     at PythonFinder.execFileCallback (/app/node_modules/node-gyp/lib/find-python.js:294:16)
48.77 gyp ERR! stack     at exithandler (node:child_process:430:5)
48.77 gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:442:5)
48.77 gyp ERR! stack     at ChildProcess.emit (node:events:517:28)
48.77 gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:290:12)
48.77 gyp ERR! stack     at onErrorNT (node:internal/child_process:477:16)
48.77 gyp ERR! stack     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
48.77 gyp ERR! System Linux 3.10.0-862.el7.x86_64
48.77 gyp ERR! command "/usr/local/bin/node" "/app/node_modules/sqlite3/node_modules/.bin/node-gyp" "rebuild"
48.77 gyp ERR! cwd /app/node_modules/sqlite3
48.77 gyp ERR! node -v v18.19.0
48.77 gyp ERR! node-gyp -v v8.4.1
48.77 gyp ERR! not ok
48.77 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
------
Dockerfile:8
--------------------
   6 |     RUN yarn config set registry http://registry.npmmirror.com 
   7 |     RUN yarn cache clean 
   8 | >>> RUN yarn install --production --force
   9 |     CMD ["node","src/index.js"]
  10 |     EXPOSE 3000
--------------------
ERROR: failed to solve: process "/bin/sh -c yarn install --production --force" did not complete successfully: exit code: 1

Look at the logs,yarn try to fetch dependencies to build Sqlite3.This is why python3 is required here.

  1. I change Dockerfile: The command RUN echo "https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.16/main" > /etc/apk/repositories and RUN echo "https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.16/community" >> /etc/apk/repositories just another mirror site config for apk,which is Alpine Linux defualt package manager tool. The command RUN apk add --no-cache --update python3 make g++ is used to install python3
# syntax=docker/dockerfile:1

FROM node:18-alpine
WORKDIR /app
COPY . .
RUN echo "https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.16/main" > /etc/apk/repositories 
RUN echo "https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.16/community" >> /etc/apk/repositories 
RUN apk add --no-cache --update python3 make g++
RUN yarn config set registry http://registry.npmmirror.com
RUN yarn cache clean
RUN yarn install --production --force
CMD ["node","src/index.js"]
EXPOSE 3000

Finally,The image has build success after 543.9 seconds.No error report:

[+] Building 543.9s (16/16) FINISHED                                                                                                                                                              docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                                        0.0s
 => => transferring dockerfile: 506B                                                                                                                                                                        0.0s
 => resolve image config for docker.io/docker/dockerfile:1                                                                                                                                                  5.5s
 => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:ac85f380a63b13dfcefa89046420e1781752bab202122f8f50032edf31be0021                                                                             0.0s
 => [internal] load metadata for docker.io/library/node:18-alpine                                                                                                                                           5.0s
 => [internal] load .dockerignore                                                                                                                                                                           0.0s
 => => transferring context: 2B                                                                                                                                                                             0.0s
 => [1/9] FROM docker.io/library/node:18-alpine@sha256:b1a0356f7d6b86c958a06949d3db3f7fb27f95f627aa6157cb98bc65c801efa2                                                                                     0.0s
 => [internal] load build context                                                                                                                                                                           0.0s
 => => transferring context: 4.78kB                                                                                                                                                                         0.0s
 => CACHED [2/9] WORKDIR /app                                                                                                                                                                               0.0s
 => [3/9] COPY . .                                                                                                                                                                                          0.1s
 => [4/9] RUN echo "https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.16/main" > /etc/apk/repositories                                                                                                         0.3s
 => [5/9] RUN echo "https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.16/community" >> /etc/apk/repositories                                                                                                   0.4s
 => [6/9] RUN apk add --no-cache --update python3 make g++                                                                                                                                                 12.6s
 => [7/9] RUN yarn config set registry http://registry.npmmirror.com                                                                                                                                        0.7s 
 => [8/9] RUN yarn cache clean                                                                                                                                                                              0.6s 
 => [9/9] RUN yarn install --production --force                                                                                                                                                           515.0s 
 => exporting to image                                                                                                                                                                                      3.3s 
 => => exporting layers                                                                                                                                                                                     3.3s 
 => => writing image sha256:56d4f7ce987b3d024f915b7f31d0e319c06e39cc1f89c6a9bcb3a0df63f2b015                                                                                                                0.0s 
 => => naming to docker.io/library/getting-started

that solved it for me, thank you . A cautious note,really

FROM arm64v8/node WORKDIR /app COPY . . RUN yarn install --ignore-engines CMD [“node”, “src/index.js”] EXPOSE 3000

This my docker file. it worked for me