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.
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
extra_hosts:
- "host.docker.internal:host-gateway"
The url hasn’t change at all and connection didn’t went through.
Smibios is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.