Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

718
Views
Access to Cosmos db emulator on local machine from Linux docker

I little confused with Linux docker and cosmos db emulator. I have an emulator installed on my local machine. On my Windows 10 I have a Linux docker container with Web API ASP.NET core application. When I try to get access from container to cosmos db I get an exception -> HttpRequestException: Connection refused.

In C# code I get needed options like AuthKey and Uri to database from environment variables. Looks like I have an issue with network between container and localhost but I can not understand how I can connect these.

Below provided docker-compose.yml and docker-compose.override.yml files.

event.webapi:
    container_name: event.webapi
    image: '${DOCKER_REGISTRY-}eventwebapi'
    environment:
     **- AzureCollectionName=Events
     - AzureDatabaseName=EventsDatabase**
    build:
      context: .
      dockerfile: src/Services/Event/Event.WebApi/Dockerfile

``` docker-compose.override.yml
event.webapi:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=https://+:443;http://+:80
      - ASPNETCORE_HTTPS_PORT=44378
      **- AzureEndpointUri=https://127.0.0.1:8081
      -AzurePrimaryKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==**
    ports:
      - "53753:80"
      - "44378:443"
    volumes:
      - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
      - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can't access vm host from docker container inside by setting https://127.0.0.1:8081 directly.

Please refer to this document, and try to set host.docker.internal:8081 to access vm host.

The host has a changing IP address (or none if you have no network access). From 18.03 onwards our recommendation is to connect to the special DNS name host.docker.internal, which resolves to the internal IP address used by the host. This is for development purpose and will not work in a production environment outside of Docker Desktop for Windows.


Cosmos DB emulator needs installed SSL certificate,according to this link. For .net runtime, you could access the certificate directly from the Windows Certificate Store.

However, you run the .net code in linux docker image.So my idea is exporting SSL certificate following these steps.

Save it in the specific path on the host and mounting host directories.Please refer to this guide.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!