使用 Docker 和 VPN 安装纱线包时出现 EAI_AGAIN 错误

发布于 2025-01-19 07:09:36 字数 873 浏览 3 评论 0原文

我正在尝试在 docker 容器内运行yarn install,并拥有这个Dockerfile

FROM node:16-alpine

ARG API_USER_TOKEN
ENV API_USER_TOKEN=$API_USER_TOKEN

WORKDIR /home/node/app
RUN chown -R node:node /home/node
USER node

COPY package.json yarn.lock .npmrc ./

RUN yarn install

COPY nest-cli.json tsconfig.json tsconfig.build.json ./

EXPOSE 9000 50051

CMD ["yarn", "start:dev"]

我得到的只是在获取纱线包时出现此错误:

error An unexpected error occurred: "https://registry.yarnpkg.com/cron-parser: getaddrinfo EAI_AGAIN registry.yarnpkg.com".

我已连接到工作< em>VPN 并在 Ubuntu 上工作,我相信这是一个 VPN 相关问题。到目前为止,我尝试了以下操作:

  1. 将 DNS 地址从 /etc/resolv.conf 文件复制到 /etc/docker/daemon.json 并重新启动 docker 服务。
  2. 尝试openconnectCisco Anyconnect
  3. 将 docker 网络设置为主机而不是网桥。

这里可能有什么问题?

I am trying to run yarn install inside a docker container, and having this Dockerfile:

FROM node:16-alpine

ARG API_USER_TOKEN
ENV API_USER_TOKEN=$API_USER_TOKEN

WORKDIR /home/node/app
RUN chown -R node:node /home/node
USER node

COPY package.json yarn.lock .npmrc ./

RUN yarn install

COPY nest-cli.json tsconfig.json tsconfig.build.json ./

EXPOSE 9000 50051

CMD ["yarn", "start:dev"]

All i get, is this error while fetching yarn packages:

error An unexpected error occurred: "https://registry.yarnpkg.com/cron-parser: getaddrinfo EAI_AGAIN registry.yarnpkg.com".

I'm connected to work VPN and working on Ubuntu, and i believe it's a VPN related issue. So far i tried this:

  1. Copying DNS adresses from /etc/resolv.conf file to /etc/docker/daemon.json and restarting docker service.
  2. Trying openconnect and Cisco Anyconnect.
  3. Setting docker network to host instead of bridge.

What could be the issue here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

Saygoodbye 2025-01-26 07:09:36

请尝试在 docker /etc/resolv.conf 中附加例如 Google DNS,如下所示:

# ... previous DNS servers
nameserver 8.8.8.8

Please try to append for example Google DNS inside docker /etc/resolv.conf like the following:

# ... previous DNS servers
nameserver 8.8.8.8
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文