使用 Docker 和 VPN 安装纱线包时出现 EAI_AGAIN 错误
我正在尝试在 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 相关问题。到目前为止,我尝试了以下操作:
- 将 DNS 地址从 /etc/resolv.conf 文件复制到 /etc/docker/daemon.json 并重新启动 docker 服务。
- 尝试openconnect和Cisco Anyconnect。
- 将 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:
- Copying DNS adresses from /etc/resolv.conf file to /etc/docker/daemon.json and restarting docker service.
- Trying openconnect and Cisco Anyconnect.
- Setting docker network to host instead of bridge.
What could be the issue here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请尝试在 docker /etc/resolv.conf 中附加例如 Google DNS,如下所示:
Please try to append for example Google DNS inside docker /etc/resolv.conf like the following: