It seems to have stopped working recently. I use docker compose to run some microservices so that unit tests can use them. Some of the microservices talk to each other, so they use a configuration value for the base URL. This is an example of my docker-compose.yml
version: '3.8' services: microsa: container_name: api.a image: ***** restart: always ports: - "20001:80" microsb: container_name: api.b image: ***** restart: always ports: - "20002:80" depends_on: microsa: condition: service_healthy environment: - ApiUrl=http://host.docker.internal:20001/api/v1/test This works perfectly on my Windows machine docker desktop, but it will not work in Azure Pipelines on either ubuntu-latest or windows-latest
- task: DockerCompose@0 displayName: 'Run docker compose for unit tests' inputs: containerregistrytype: 'Azure Container Registry' azureSubscription: ${{ parameters.azureResourceManagerConnection }} azureContainerRegistry: ${{ parameters.acrUrl }} dockerComposeFile: 'docker-compose.yml' action: 'Run services' When api.b attempts to call api.a, I get the following exception:
No such host is known. (host.docker.internal:20001)
Using http://microsa:20001/... gives the following error:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (microsa:20001)
I've also tried http://localhost:20001/...
I've also confirmed that microsa is accessible directly, so there is no errors within that container.
I've also tried running docker-compose up via AzureCLI@2 instead of DockerCompose@0 with the same results
host.docker.internalis currently only supported by default on Docker Desktop; unless Azure had specific options to support this, I'm not sure how that worked before. That said; is there a reason to publish the ports, and not connect to the other service using the "internal" network by connecting to the other service by its name? Might need to change service-names to not have a.?.and tried bothlocalhostandmicrosawith the same results.