First to be clear, my docker container has an IP address under NetworkSettings.Networks.bridge
. That IP is 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
My research shows its rough working with docker locally on windows. In following this short guide: https://blog.sixeyed.com/published-ports-on-windows-containers-dont-do-loopback/
I come across using the network NAT IP address. I see this recommended a few places. But that section of my docker inspect
does not exist at all.
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. 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. Any help is appreciated. Here is the 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. It is fixed in 19.03. So try updating your docker engine.