Cannot access app by container IP

I can see the app on localhost. But I need to access it by IP as well. I have read similar threads but all in vain.

docker inspect shows 172.17.0.2. Why can’t I see my app when I go to that IP? Why is it just localhost?

Also, how can I get the VM IP?

1 Like

I just had the same issue. It looks like there is automatic mapping happening in docker for mac. So if you do a -v 3000:3000 for instance then automatically this port gets mapped to Mac port 3000, but the behavior seems unreliable. I’ve been trying to use node-inspector on port 8080 and it has worked once but then fails.

You might want to look into these threads:

@Andrii Parfonov, do you solve your problem ? I’ve the same problem. I tested on a Linux distribution and it’s working.

On Docker4Mac (1.12.2) i can’t use any container by IP.

Mickael

I thought I had this problem: the docs don’t say exactly clearly what will happen when switching from docker-machine/vbox (of Docker Toolbox) to D. for Mac and basically no network access was working, automatic or -p explicit, container IP (found only via network inspect or host IP.

I eventually realized that run parameters must come before, not after, the image name. doh Then forwarding turned out to be working just fine.

Not sure but that might be something that has changed in recent versions.

So you should be able to access containers from your container host using the container IP . You can use docker inspect <container ID> to get your container’s IP address.

Does that answer your question?