docker 容器执行 yarn 问题 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
yadgen
V2EX    前端开发

docker 容器执行 yarn 问题

  •  
  •   yadgen 2024-09-15 01:15:39 +08:00 1368 次点击
    这是一个创建于 390 天前的主题,其中的信息可能已经有所发展或是发生改变。

    本机是 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:8) 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-09-15 12:16:40 +08:00
    yarn 换成 pnpm 试试
    yadgen
        2
    yadgen  
    OP
       2024-09-15 15:01:17 +08:00
    @JetMac 好的,谢谢
    JetMac
        3
    JetMac  
       2024-09-15 16:03:47 +08:00
    实不行用 Github action 来 build
    yadgen
        4
    yadgen  
    OP
       2024-09-17 17:03:38 +08:00
    @JetMac
    国外的 github ,人家 Dockerfile 用的是 yarn install & yarn build
    可不可以有其他方法解决这个问题?
    yadgen
        5
    yadgen  
    OP
       2024-09-17 17:51:04 +08:00
    @JetMac
    我发现一个问题,我不用 Dockerfile 执行 yarn install & yarn build
    手动运行镜像,运行命令,是可以的。
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2594 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 25ms UTC 15:21 PVG 23:21 LAX 08:21 JFK 11:21
    Do have faith in what you're doing.
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86