docker 容器执行 yarn 问题

yadgen · 2024-9-15 01:15:39 · 92 次点击
本机是 win11 ,安装了 vmare ,安装了 ubuntu22.04 ,安装了 docker ,容器执行命令得到如下网络错误信息:

```
27.97 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
27.97 error AggregateError [ETIMEDOUT]:
27.97     at internalConnectMultiple (node:net:1118:18)
27.97     at internalConnectMultiple (node:net:1186:5)
27.97     at Timeout.internalConnectMultipleTimeout (node:net:1712:5)
27.97     at listOnTimeout (node:internal/timers:583:11)
27.97     at process.processTimers (node:internal/timers:519:7)
27.98 error https://registry.yarnpkg.com/turbo-darwin-64/-/turbo-darwin-64-2.1.1.tgz:
27.98 error https://registry.yarnpkg.com/turbo-windows-64/-/turbo-windows-64-2.1.1.tgz:
27.98 error https://registry.yarnpkg.com/turbo-darwin-arm64/-/turbo-darwin-arm64-2.1.1.tgz:
27.98 error https://registry.yarnpkg.com/turbo-linux-arm64/-/turbo-linux-arm64-2.1.1.tgz:
27.98 error https://registry.yarnpkg.com/turbo-windows-arm64/-/turbo-windows-arm64-2.1.1.tgz:
27.98 error https://registry.yarnpkg.com/turbo-linux-64/-/turbo-linux-64-2.1.1.tgz:
31.00 info There appears to be trouble with your network connection. Retrying...
37.03 info There appears to be trouble with your network connection. Retrying...
43.04 info There appears to be trouble with your network connection. Retrying...
49.07 info There appears to be trouble with your network connection. Retrying...
------
Dockerfile:8
--------------------
   6 |     WORKDIR /app
   7 |     COPY . /app/
   8 | >>> RUN yarn install && yarn build
   9 |     
  10 |     WORKDIR /app/packages/tracker
--------------------
ERROR: failed to solve: process "/bin/sh -c yarn install && yarn build" did not complete successfully: exit code: 1
```

虚拟使用的是桥接,浏览器和终端都可以使用 VPN
Dockerfile 增加一些命令
当然是在 yarn install 之前增加的

```
RUN yarn config set registry https://registry.npmjs.org/
RUN yarn config set proxy xxx
RUN yarn config set https-proxy xxx
```

给 npm 、yarn 、docker 设置代理和替换镜像源,都没有效果。
网上搜了很多答案,都没有解决。
不知道有没有大佬知道如何解决这个问题,非常感谢。
举报· 92 次点击
登录 注册 站外分享
1 条回复  
JetMac 小成 2024-9-15 12:16:40
yarn 换成 pnpm 试试
返回顶部