[英]Windows Docker Container has no NAT IP Address. Cannot access container locally
First to be clear, my docker container has an IP address under NetworkSettings.Networks.bridge
. 首先要弄清楚,我的docker容器在
NetworkSettings.Networks.bridge
下具有IP地址。 That IP is 172.17.0.2
该IP为
172.17.0.2
However I cannot access the container via http://172.17.0.2:3000/
after running it with docker run -p 3000:3000 node:8.10.0
但是在使用
docker run -p 3000:3000 node:8.10.0
运行容器后,我无法通过http://172.17.0.2:3000/
访问容器
My research shows its rough working with docker locally on windows. 我的研究表明,它在Windows本地与docker进行粗略合作。 In following this short guide: https://blog.sixeyed.com/published-ports-on-windows-containers-dont-do-loopback/
在遵循此简短指南后: https : //blog.sixeyed.com/published-ports-on-windows-containers-dont-do-loopback/
I come across using the network NAT IP address. 我遇到了使用网络NAT IP地址的问题。 I see this recommended a few places.
我看到这推荐了几个地方。 But that section of my
docker inspect
does not exist at all. 但是我的
docker inspect
这一部分根本不存在。 It returns: 它返回:
"NetworkSettings": {
"Bridge": "",
"SandboxID": "0c81d8f7ce5bcba70ec0487bbfe91bc6f221e29d9378c33708fac78d0ae47d3e",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"3000/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "3000"
}
]
},
"SandboxKey": "/var/run/docker/netns/0c81d8f7ce5b",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "bbe5f42a5b53c001bd3c2852bc6b22976fb9bab2afcb88b30f6660d7662f526f",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "0af66a62bc57ce25491c82f5a13d947ca79f5a879f3c1a6db40a90233eeb04f8",
"EndpointID": "bbe5f42a5b53c001bd3c2852bc6b22976fb9bab2afcb88b30f6660d7662f526f",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
}
}
As you can see the NAT section is missing entirely. 如您所见,NAT部分完全丢失了。 I cant find anything online that mentions why or how to resolve.
我在网上找不到任何提及原因或解决方法的内容。 I was hoping it missing would be a good thing and make it easier to connect.
我希望它丢失是一件好事,并使连接更容易。 Alas it does not.
las,事实并非如此。 Any help is appreciated.
任何帮助表示赞赏。 Here is the dockerfile:
这是dockerfile:
FROM node:8.10.0
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
CMD ["./node_modules/gulp/bin/gulp.js", "assets"]
CMD [ "node", "app.js" ]
EXPOSE 3000
That's a known bug under docker windows. 这是在Docker视窗下的已知错误。 It is fixed in 19.03.
它已在19.03中修复。 So try updating your docker engine.
因此,尝试更新您的Docker引擎。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.