Reach host from inside a container in a costum network

So I have created a network like:

Driver bridge
Scope local
Attachable false
Internal false
IPV4 Subnet

I have a container at that needs to reach the host IP which I know is always in Docker.

The issue is that if I do a ping, the container sees the IP but if I do a curl -X POST I have a couldn't connect to the server error

How can I reach the host?

If ping works but curl not, then there may be no service listening on the targeted port of the IP.

there is, as I can curl from host to that specific ip:port and it answers correctly

Since you are using the same curl command with the same IP address on the host and if ping works, all that remains is a firewall that blocks UDP/TCP packages while ping is ICMP which could be blocked too but not always is. Locally it wouldn’t matter if you can ping a private IP address but you sometimes you don’t want a container to access anything on the host. That is not a default setting at least not in Docker so something else must have blocked the request. Here is an article (and video) in which I share some thoughts about Docker networks and how you can debug it.

1 Like