Is there a way for hitting the host.docker.internal from local machine?

Quickly about service

While writing docker compose for service i ran into issue. There are 4 parts that are required for service to fully work e2e on docker that is frontend in angular, backend in c# .net 6, azure function that is triggered by file on azure blob (not important in that issue) and azurite. Frontend task is to put files into azure storage after receiving SAS token embedded into URI address that backend creates. This fully work.

What’s the issue

When containerized SAS URI created by backend application looks like: http://host.docker.internal:10000/devstoreaccount1/user-uploads/3415dfde-636c-4f4e-b7ef-bfeb456466f3.zip.zip?{SAS_TOKEN_PART} and with that frontend application opened locally on machine cannot do request as DNS can’t resolve its name. And i want to be able to connect to azurite from outside the docker from frontend application (it’s possible only the address is issue). I would like to omit conditional compilation on backend with replacing strings when it’s in docker environment. I believe there is a solution i just can’t find it.

Docker compose:

Parts of docker-compose.yml were censored but i think context is meaningless in that case.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>version: '3'
services:
api:
build:
context: CENSORED
dockerfile: Dockerfile
depends_on:
- azurite
environment:
- DOCKER_URL=DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://host.docker.internal:10000/devstoreaccount1;
volumes:
- "${HOME}/.azure:/root/.azure"
ports:
- 443:443
- 80:80
azurite:
image: mcr.microsoft.com/azure-storage/azurite
ports:
- 10000:10000
volumes:
- ./data:/data
command: azurite --loose --blobHost 0.0.0.0 --blobPort 10000
functions:
build:
context: CENSORED
dockerfile: Dockerfile
ports:
- 7071:7071
depends_on:
- azurite
frontend:
build:
context: CENSORED
dockerfile: Dockerfile
ports:
- 4200:4200
</code>
<code>version: '3' services: api: build: context: CENSORED dockerfile: Dockerfile depends_on: - azurite environment: - DOCKER_URL=DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://host.docker.internal:10000/devstoreaccount1; volumes: - "${HOME}/.azure:/root/.azure" ports: - 443:443 - 80:80 azurite: image: mcr.microsoft.com/azure-storage/azurite ports: - 10000:10000 volumes: - ./data:/data command: azurite --loose --blobHost 0.0.0.0 --blobPort 10000 functions: build: context: CENSORED dockerfile: Dockerfile ports: - 7071:7071 depends_on: - azurite frontend: build: context: CENSORED dockerfile: Dockerfile ports: - 4200:4200 </code>
version: '3'
services:
  api:
    build:
      context: CENSORED
      dockerfile: Dockerfile
    depends_on:
      - azurite
    environment:
      - DOCKER_URL=DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://host.docker.internal:10000/devstoreaccount1;
    volumes:
      - "${HOME}/.azure:/root/.azure"
    ports:
      - 443:443
      - 80:80
  azurite:
    image: mcr.microsoft.com/azure-storage/azurite
    ports:
      - 10000:10000
    volumes:
      - ./data:/data
    command: azurite --loose --blobHost 0.0.0.0 --blobPort 10000
  functions:
    build:
      context: CENSORED
      dockerfile: Dockerfile
    ports:
      - 7071:7071
    depends_on:
      - azurite
  frontend:
    build:
      context: CENSORED
      dockerfile: Dockerfile
    ports:
      - 4200:4200

My specs

  • Macbook Pro M2 Pro

  • It should also be working with windows.

  • Tried with creating networks and putting everything in network

  • Tried adding

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>extra_hosts:
- "host.docker.internal:host-gateway"
</code>
<code>extra_hosts: - "host.docker.internal:host-gateway" </code>
extra_hosts:
    - "host.docker.internal:host-gateway"

The url hasn’t change at all and connection didn’t went through.

New contributor

Smibios is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật