Hi I have a question.
I am using docker compose ver3 and consul image as container, on my host machine I have a simple service that should response to http request and it is set on port 40001. So now I want to make docker send requests to this service as health check through http (in other words send request from docker container to service that is running on host).
My docker compose for consul is simple:
version: '3'
services:
consul:
image: consul:latest
command: consul agent -dev -log-level=warning -ui -client=0.0.0.0
hostname: consul
container_name: consul
ports:
- 8500:8500
- 8600:8600/udp
- 40000-41000:40000-41000
So I startup this container, service on host is registered inside it with http health check address for service on host with is "http://localhost:40005//Health". Interval for request is about 15 seconds so I expect such a request arrives on service and service will response with 200.
Also I have access to UI for consul in container.
Well service on host does not register any incoming request, but interesting thing is when I run stand-alone consul it works fine (that is I am getting health checks).
So my question is, is this could be the problem that container can not communicate with service on host.
For the example, lets say that you have a service running on port 5555 on your host.
Below are the four solutions if you want to communicate to your host from a docker container :
docker0
and it's IP address is something like 172.17.0.1
(you have to check those value).http://172.17.0.1:5555
host.docker.internal
(here is the doc).http://host.docker.internal:5555
.http://host.docker.internal:5555
.http://[host_public_ip_or_dns]:5555
.