I run the container with the following command docker run -p 8081:5000 eliassal/colourapi
When I try to access the web page with http:'//localhost:8081 or try to ping the IP 172.17.0.4 it just dont go through.
what is strange is that when I check Resources > Network, I see that docker desktop uses 192.168.65.0/24 subnet which is completly different from the IP of the container.
I visited the âExecâ tab and discovered that curl is not available, I tried to install it but it seems thcontainer is not able to reach the internet as well.
Since the containers are running in the virtual machine of Docker, you wonât be able to ping the container IPs and the IP or subnet of the Docker Desktop environment is not really relevant here unless you have the same or colliding subnet in your LAN. Interestingly, I tried that too and I still had no network issue on macOS.
You can still try to change the subnet of Docker dEsktop, if you want.
Please, share the error message which makes you think that.
And also any error message or sign that you got when trying to access the container on localhost using the forwarded port.
One idea until you share more info: Your service in the container has to listen on 0.0.0.0, not a local IP, not localhost.
but I donât see how it handles the IP. Not important if you can test the URL from inside the container. If it doesnât have curl, you can try wget.
If the APP doesnâT return a response, it is an application issue, not a Dockr issue.
Empty response probably means the port mapping worked. You can test it by stopping the container and reloading the page. But what is âsalam7â in the URL? Why isnât it localhost?
Iâm not sure what you mean by it. My previous question was about the internet access of the container. How is the container IP relevant, since you would not be able to access it from the host?
Thanks rimelek, yes it is an issue with the application. I created a new project in visual studio, after compiling and creating a container I was able to access the API in the container.
For the 1st app, I posted the issue to Visual studio support forum.
But tell me please, why it is not possible to ping the container? This the 1st thing to do to check connectivity, how can we check connectivity of a container when there is an issue? 2nd, I still dont understand why in settings of docker desktop it is indicated 192.168.65.0/24 subnet but my containers get IPs in the 172.17.0.0 subnet. Does this mean that this setting is not considered and docker attributes the subnet that it choses internally. When you say âYou can still try to change the subnet of Docker Desktopâ, this will not be useful as docker is not taking it into consideration, NO?
Thatâs not how things are done in the container world, especially not with Docker Desktop, where the docker engine runs in a utility vm within a natted network. How do you expect to ping an ip where no route points to it? Traffic into the utility vm is handled by port forwarding, the same is true from the docker engine inside the utility vm to a container in a container network.
Both are correct. The first is the subnet the WSL2 utility vm works in, the 2nd in the subnet of the default docker network. You can list them with docker network ls, and inspect their details with docker network inspect <networkname> (of course <networkname> is just a placeholder).
It is useful when experience a collision between the ip range of your host network, and the network wsl uses.
Whenever you create a docker network. For instance every new docker compose deployment creates at least one default network, and all other networks you might have added as well.
Yes, as you can also use a computer at home behind your home router and still access the internet. It wouldnât be really useful if the way Docker Desktop works didnât allow internet access
but I still donât know why you say you have no internet access. Excuse me if I missed where you replied to that part of my previous question or if I misunderstood something.
It is possible that the internet access doesnât work, as it happened to some people, but usually caused by a proxy or VPN. I think you only showed what you saw when you tried to access the container so far.