简体   繁体   English

Windows Docker容器没有NAT IP地址。 无法在本地访问容器

[英]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.

相关问题 Windows 10上的docker:容器没有IP地址 - docker on windows 10: container has no ip address 我的Docker容器没有IP地址。 为什么? - My Docker container does not have IP address. Why? Docker-Windows上容器的IP地址 - Docker - IP address of container on Windows 如何在 Windows 10 上通过 DockerNAT IP 地址访问 Docker 容器? - How to access Docker container through DockerNAT IP address on Windows 10? Docker(已停止)容器没有 IP 地址 - Docker (stopped) container has no IP address 无法使用 IP 地址访问本地 docker 容器 - Unable to access local docker container with IP address Docker容器IP地址 - Docker container IP address 如何在 Docker 桌面 Windows 10 中使用 IP ADDRESS 从主机访问容器(尤其是使用 Z05E406053C418A2DA1) - How to access container from host using IP ADDRESS in Docker Desktop Windows 10 (esspecially with use docker compose)? Docker:无法访问具有给定IP地址/令牌的(Jupyter Data Science)Docker容器? 为什么端口错误? - Docker: cannot access (jupyter data science) docker container with given IP address/token? Why is the port wrong? 来自 docker 容器的公开端口无法通过 RedHat 8 中的 IP 地址访问主机服务器 - Exposed ports from docker container cannot able to access on host server by IP Address in RedHat 8
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM