docker / getting-started

Getting started with Docker
Apache License 2.0
2.91k stars 6.4k forks source link

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

Open bastarte opened 1 year ago

bastarte commented 1 year ago

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 ?

letelumiere commented 1 year ago

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.

mmdmurphy commented 1 year ago

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.

rashiddilkash commented 1 year ago

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

pframpto commented 1 year ago

That worked for me but only after I took out --production so on the Dockerfile my line read: RUN yarn install --ignore-engines

thanks Rashiddilkash

royzhao7 commented 1 year ago

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

yibajianghudao commented 1 year ago

That worked for me. Thanks Rashiddilkash.

yibajianghudao commented 1 year ago

when i first, my Dockerfile is: RUN yarn install --product --ignore-engines it's worked for me. But second, RUN yarn install --ignore-engines it's worked for me. thanks.

dradice commented 1 year ago

I had the same issue on Pop!_OS 22.04 (an Ubuntu 22.04 derivative) using Docker Desktop. The solution was to add

"dns": [
    "8.8.8.8"
  ],

To the Docker Engine config file (under Settings -> Docker Engine). Now my config file reads

{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "dns": [
    "8.8.8.8"
  ],
  "experimental": false
}
georgetalamantez commented 1 year ago

pay 1 million ounces of laddie gold to Austin Greene and he will aprove this. He promises!

On 9/13/23, David Radice @.***> wrote:

I had the same issue on Pop!_OS 22.04 (an Ubuntu 22.04 derivative) using Docker Desktop. The solution was to add

"dns": [
    "8.8.8.8"
  ],

To the Docker Engine config file (under Settings -> Docker Engine). Now my config file reads

{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "dns": [
    "8.8.8.8"
  ],
  "experimental": false
}

-- Reply to this email directly or view it on GitHub: https://github.com/docker/getting-started/issues/381#issuecomment-1717913786 You are receiving this because you are subscribed to this thread.

Message ID: @.***>

chy2948331536 commented 1 year ago

hello! I not search the error of failed to solve: process "/bin/sh -c yarn install --production" did not complete successfully: exit code: I search the error /app/node_modules/sqlite3: Command failed.

Then I realized that there might be a missing package called npm(The World's Largest Software Registry (Library)) I run sudo apt install npm the docker build -t getting-started . go to the next step and complete

output: (base) caodd@PowerEdge:~/program/getting-started-app$ docker build -t getting-started . [+] Building 20.2s (11/11) FINISHED docker:default => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 180B 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => resolve image config for docker.io/docker/dockerfile:1 1.7s => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:ac85f380a63b13dfcefa89046420e1781752bab202122f8f50032edf31be0021 0.0s => [internal] load metadata for docker.io/library/node:18-alpine 1.1s => [1/4] FROM docker.io/library/node:18-alpine@sha256:3482a20c97e401b56ac50ba8920cc7b5b2022bfc6aa7d4e4c231755770cf892f 0.0s => [internal] load build context 0.0s => => transferring context: 11.14kB 0.0s => CACHED [2/4] WORKDIR /app 0.0s => CACHED [3/4] COPY . . 0.0s => [4/4] RUN yarn install --production 15.5s => exporting to image 1.6s => => exporting layers 1.6s => => writing image sha256:2748a5a2cb58bfe3ba9cc70b50721704e7582d1582457b07e1fdf258afe209d0 0.0s => => naming to docker.io/library/getting-started 0.0s

What's Next?

  1. Sign in to your Docker account → docker login
  2. View a summary of image vulnerabilities and recommendations → docker scout quickview (base) caodd@PowerEdge:~/program/getting-started-app$
MislavJuric commented 1 year ago

I am having the same issue. None of the suggestions above worked for me.

As suggested by #347, when I try to run:

docker run busybox nslookup registry.yarnpkg.com

I get the following output:

Unable to find image 'busybox:latest' locally
latest: Pulling from library/busybox
3f4d90098f5b: Pull complete 
Digest: sha256:3fbc632167424a6d997e74f52b878d7cc478225cffac6bc977eedfe51c7f4e79
Status: Downloaded newer image for busybox:latest
;; connection timed out; no servers could be reached
knowledegeupup commented 1 year ago

I have the same question and None of the suggestions above worked for me.

shirakuyanai commented 1 year ago

I'm not sure why but leaving the --production flag doesn't work anymore since 1.0.4 Bun update. Does it have any effect at all on performance or any difference from not having it?

satishattada commented 12 months ago

Please make sure, you have configured .env file in the project level

diogovh commented 11 months ago

Tive o mesmo problema no Pop! _OS 22.04 (um derivado do Ubuntu 22.04) usando o Docker Desktop. A solução foi adicionar

"dns": [
    "8.8.8.8"
  ],

Para o arquivo de configuração do Docker Engine (em Configurações -> Docker Engine). Agora meu arquivo de configuração diz

{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "dns": [
    "8.8.8.8"
  ],
  "experimental": false
}

Deu certo. Obrigado!!

JeffUlan commented 11 months ago

ubuntu22.04 I don't know the correct way yet

Enkratia commented 11 months ago

In my case i just needed to read what docker is writing above process "/bin/sh -c yarn install --production" did not complete successfully: exit code: 1 line and then debug it.

In my case docker didn't understand what path @components mean and didn't see one dependency because it was dev. dependency instead of pure dependency in package.json

soohofather commented 10 months ago

"RUN yarn install --production --ignore-engines" is work for me

bert1961 commented 10 months ago

I had the same issue on Pop!_OS 22.04 (an Ubuntu 22.04 derivative) using Docker Desktop. The solution was to add

"dns": [
    "8.8.8.8"
  ],

To the Docker Engine config file (under Settings -> Docker Engine). Now my config file reads

{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "dns": [
    "8.8.8.8"
  ],
  "experimental": false
}

that solved it for me, thank you dradice. I'm on debian12 and had to create /etc/docker/daemon.json with this content. 👍

sergeykad commented 10 months ago

I am getting similar errors randomly for the RUN --mount=type=cache,target=/var/cache/apk apk add rsync openssh line. The returned error codes are 7 or 3.

It started happening after we switched to Docker bake.

ERROR: failed to solve: process "/bin/sh -c apk add rsync openssh" did not complete successfully: exit code: 3

shadowmoss commented 8 months ago

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.

  2. 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

4. 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. (/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

Kano-iso commented 8 months ago

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

navidshad commented 6 months ago

Github Action ( Ubuntu runner )

If you want to build for arm arch and get the error on an ubuntu runner, then you need to prepare the environment before start building the image:

steps:
     # Put these steps before docker build
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1