rancher-desktop: Long wait and network errors on npm install in Rancher container

Actual Behavior

Running npm ci with a large number of packages results in over 5 minutes of wait and EHOSTUNREACH or EAI_AGAIN errors.

Steps to Reproduce

  1. Clone the reproduction repo: https://github.com/hdodov/mcve-rancher-npm-hang
  2. Run npm run dev
  3. You should see one of the errors I got

Result

First attempt:

[+] Building 308.6s (8/9)                                                               docker:default
 => [payload internal] load build definition from Dockerfile                                      0.0s
 => => transferring dockerfile: 182B                                                              0.0s
 => [payload internal] load .dockerignore                                                         0.0s
 => => transferring context: 2B                                                                   0.0s
 => [payload internal] load metadata for docker.io/library/node:18-bullseye-slim                  2.6s
 => [payload internal] load build context                                                         0.0s
 => => transferring context: 72B                                                                  0.0s
 => [payload 1/5] FROM docker.io/library/node:18-bullseye-slim@sha256:f06f9ff9dcc5cfec936a7bf085  0.0s
 => CACHED [payload 2/5] WORKDIR /app                                                             0.0s
 => CACHED [payload 3/5] COPY package-lock.json .                                                 0.0s
 => CACHED [payload 4/5] COPY package.json .                                                      0.0s
 => [payload 5/5] RUN npm ci                                                                    306.0s
failed to solve: Unavailable: error reading from server: EOF

Second attempt:

[+] Building 624.4s (9/9) FINISHED                                                      docker:default
 => [payload internal] load .dockerignore                                                         0.0s
 => => transferring context: 2B                                                                   0.0s
 => [payload internal] load build definition from Dockerfile                                      0.0s
 => => transferring dockerfile: 182B                                                              0.0s
 => [payload internal] load metadata for docker.io/library/node:18-bullseye-slim                  3.4s
 => [payload 1/5] FROM docker.io/library/node:18-bullseye-slim@sha256:f06f9ff9dcc5cfec936a7bf085  0.0s
 => [payload internal] load build context                                                         0.0s
 => => transferring context: 72B                                                                  0.0s
 => CACHED [payload 2/5] WORKDIR /app                                                             0.0s
 => CACHED [payload 3/5] COPY package-lock.json .                                                 0.0s
 => CACHED [payload 4/5] COPY package.json .                                                      0.0s
 => ERROR [payload 5/5] RUN npm ci                                                              558.7s
------                                                                                                 
 > [payload 5/5] RUN npm ci:                                                                           
549.4 npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
549.9 npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
558.5 npm notice 
558.5 npm notice New minor version of npm available! 10.2.3 -> 10.3.0
558.5 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.3.0>
558.5 npm notice Run `npm install -g npm@10.3.0` to update!
558.5 npm notice 
558.5 npm ERR! code EAI_AGAIN
558.5 npm ERR! syscall getaddrinfo
558.5 npm ERR! errno EAI_AGAIN
558.5 npm ERR! request to https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org

Here’s an error I got when manually entering the container shell and running npm ci:

root@fe61caa23d72:/app# npm ci
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated @types/sharp@0.32.0: This is a stub types definition. sharp provides its own type definitions, so you do not need this installed.
npm notice 
npm notice New minor version of npm available! 10.2.3 -> 10.3.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.3.0
npm notice Run npm install -g npm@10.3.0 to update!
npm notice 
npm ERR! code EHOSTUNREACH
npm ERR! syscall connect
npm ERR! errno EHOSTUNREACH
npm ERR! request to https://registry.npmjs.org/async/-/async-2.6.4.tgz failed, reason: connect EHOSTUNREACH 104.16.25.34:443

This is the complete npm log of this run: npm-EHOSTUNREACH.log.

However, when I manually ran it later, it worked:

root@5e7e6a9d2f90:/app# npm ci
npm WARN deprecated @types/sharp@0.32.0: This is a stub types definition. sharp provides its own type definitions, so you do not need this installed.
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.

added 1423 packages, and audited 1424 packages in 43s

224 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Expected Behavior

The whole container build should take about 50 seconds, as it does with OrbStack and Docker Desktop.

Additional Information

No response

Rancher Desktop Version

1.12.1

Rancher Desktop K8s Version

deactivated

Which container engine are you using?

moby (docker cli)

What operating system are you using?

macOS

Operating System / Build Version

macOS Sonoma 14.3

What CPU architecture are you using?

x64

Linux only: what package format did you use to install Rancher Desktop?

None

Windows User Only

No response

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 7
  • Comments: 15 (7 by maintainers)

Most upvoted comments

This might be related to #6358, which also appears to occur due to network errors in the container.

I’m having this issue using Mac Os M1 Sonoma 14.1.1. Rancher Desktop using QEMU virtualization used to work 😢

It looks like buildkit is not properly enabled by default in Rancher Desktop;

This turned out to be wrong. The reason that buildkit was not being used was because I still had a custom builder installed from investigating a different issue, and that builder was also made the default:

$ docker buildx ls
NAME/NODE         DRIVER/ENDPOINT  STATUS  BUILDKIT        PLATFORMS
amd64builder *    docker-container
  amd64builder0   rancher-desktop  running v0.12.5         linux/arm64, linux/amd64, linux/amd64/v2
default           docker
  default         default          running v0.10.6+d52b2d5 linux/arm64, linux/amd64, linux/amd64/v2
rancher-desktop   docker
  rancher-desktop rancher-desktop  running v0.10.6+d52b2d5 linux/arm64, linux/amd64, linux/amd64/v2

The builder config is not deleted by a factory reset (I’ve created #6408 to change this), so it affected my testing for this issue as well by running the build inside a container.

After deleting the custom builder, the docker compose up --build worked normally and compled the npm ci command in under 40s.

Deleting the builder did not help with the QEMU issue though; it would still lose the socket connection and eventually time out.