docker 容器执行 yarn 问题

4 天前
 yadgen

本机是 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 设置代理和替换镜像源,都没有效果。 网上搜了很多答案,都没有解决。 不知道有没有大佬知道如何解决这个问题,非常感谢。

433 次点击
所在节点    前端开发
5 条回复
JetMac
4 天前
yarn 换成 pnpm 试试
yadgen
4 天前
@JetMac 好的,谢谢
JetMac
4 天前
实不行用 Github action 来 build
yadgen
2 天前
@JetMac
国外的 github ,人家 Dockerfile 用的是 yarn install & yarn build
可不可以有其他方法解决这个问题?
yadgen
2 天前
@JetMac
我发现一个问题,我不用 Dockerfile 执行 yarn install & yarn build
手动运行镜像,运行命令,是可以的。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1073139

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX