docker - 无法从容器内部连接到内部网络
问题描述
我有以下 Dockerfile:
FROM node:8
WORKDIR /tmp
COPY package.json /tmp/
RUN npm config set registry http://xxx:8081/repository/npm-group/
RUN npm install
WORKDIR /opt/app
COPY . /opt/app/
RUN cp -a /tmp/node_modules /opt/app/
EXPOSE 3000
ENTRYPOINT [ "npm", "start" ]
当我尝试使用以下方法构建图像时:
docker build -t blah .
一切顺利,直到我进入第 5/10 步,npm install。日志显示:
npm ERR! errno ETIMEDOUT
npm ERR! network request to http://xxx:8081/repository/npm-group/prop-types failed, reason: connect ETIMEDOUT x.x.x.x:8081
我不知道发生了什么。Nexus 存储库托管在内部网络上,所以我不知道为什么无法联系到它。
iptables 显示以下内容:
philippe@laptop:~/localdev/react-starterkit$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
DOCKER-USER all -- anywhere anywhere
DOCKER-ISOLATION-STAGE-1 all -- anywhere anywhere
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
DOCKER all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain DOCKER (1 references)
target prot opt source destination
Chain DOCKER-ISOLATION-STAGE-1 (1 references)
target prot opt source destination
DOCKER-ISOLATION-STAGE-2 all -- anywhere anywhere
RETURN all -- anywhere anywhere
Chain DOCKER-ISOLATION-STAGE-2 (1 references)
target prot opt source destination
DROP all -- anywhere anywhere
RETURN all -- anywhere anywhere
Chain DOCKER-USER (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
有任何想法吗?
解决方案
我使用https://stackoverflow.com/a/45644890/2122950解决 了我公司的 DNS 在 /etc/resolv.conf 中不存在
推荐阅读
- spring - 如何验证 DTO 字符串字段是指定值之一
- r - 在 R 中使用突变
- c# - InvalidOperationException:方案已存在:Identity.Application
- kotlin - 暂停直到 StateFlow 达到所需状态之一并返回结果
- floating-point - ARM Cortex-A9 NEON 和 VFP
- mysql - 将一个表与多个表相关联的数据库模式
- reactjs - 编辑对象状态数组
- maven - 如何在 Maven 构建的詹金斯管道中增加百分比代码覆盖率
- android - 无法在对话框片段中的文本视图上设置文本
- amazon-web-services - 我的弹性搜索批量索引器未正确关闭