I have a .net application running in a docker container via docker compose. I'm using a Windows machine with Docker Desktop running Linux containers.
The application connects to a Cosmos instance. The account key is set to the emulator key by default.
Here is the section from docker-compose.yml
customerapi:
container_name: mycustomerapi
image: acr.io/customer-api:master
ports:
- "20102:80"
environment:
- ASPNETCORE_ENVIRONMENT=Development
- CosmosOptions__Endpoint=${endpoint}
- CosmosOptions__DisableSsl=true
If I override the account key and endpoint, I can get the application to connect using a real instance hosted in Azure, but I can't get it to connect to the emulator running on the host machine.
I've tried setting ${endpoint} to the following values with no luck;
- https://host.docker.internal:8081/ Fails after about 5 mins with the error
System.Net.Http.HttpRequestException: Connection refused (127.0.0.1:8081)
. - https://192.168.10.110:8081/ This is my local IP address. It fails much faster (around 10 seconds) with the same error as above.
I've also tried using network_mode: host
with both endpoints.
- https://host.docker.internal:8081/ Fails with the same error as above.
- https://192.168.10.110:8081/ Fails after about 10 seconds with the error
System.Net.Http.HttpRequestException: No route to host (192.168.10.110:8081)