IP address of container will be available to host for connection
Actual behavior
Cannot access, no route to host
Information
By default dockerNAT assigns 10.0.75.0/24 to MobyLinuxVM.
Docker inside MobyLinuxVM assigns to containers IP addresses in range 172.17.0.0/16. You have to alter route tables to access containers IP address:
In fact I have a completely opposite problem.
I started a SQL Server 2016 express container and the SQL Server instance is visible and accessible from all the machine s except the host machine.
I tries all the combinations of hostname\SQLexpress but to no avail.
Then I found out the conatiner address and tried connecting to it and it worked.
Still confused. though.
Is this fix just for VMs? I have this issue connecting to Linux containers using the python:slim-buster image for flask applications. I can browse webpages hosted on containers prior to bringing my containers up with docker-compose. After they’re connected to the 172.17.X.X network, adding routes does not solve problem.
I have tried different combinations for gateway IP including container IP and actual gateway of docker-compose network.
In order to make it work your VM should act as a router and the VM’s IP address should be visible from Windows. In the recent Docker Desktop versions it does not seem to be the case.
If you want to access the services, you need to forward ports (docker run -p 8080:80 ...)
If you just want to test if a service is listening on the proper internal IP address, you can try this:
docker run --rm -it --net host nicolaka/netshoot wget -O- http://172.17.0.2