yadgen
V2EX  ›  前端开发

docker 容器执行 yarn 问题

By yadgen at 2024 年 9 月 15 日 · 2254 次点击

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

5 条回复  •  2024-09-17 17:51:04 +08:00
JetMac
   1
JetMac  
   2024 年 9 月 15 日
yarn 换成 pnpm 试试
yadgen
   2
yadgen  
OP
   2024 年 9 月 15 日
@JetMac 好的,谢谢
JetMac
   3
JetMac  
   2024 年 9 月 15 日
实不行用 Github action 来 build
yadgen
   4
yadgen  
OP
   2024 年 9 月 17 日
@JetMac
国外的 github ,人家 Dockerfile 用的是 yarn install & yarn build
可不可以有其他方法解决这个问题?
yadgen
   5
yadgen  
OP
   2024 年 9 月 17 日
@JetMac
我发现一个问题,我不用 Dockerfile 执行 yarn install & yarn build
手动运行镜像,运行命令,是可以的。
© 2026 V2EX · 35ms · 3.9.8.5