Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to connect to Azure Storage Emulator from a docker container on the same machine

I dockerized a .net core 2.2 web api application in Visual Studio 2017 successfully. One part of this application is supposed to store some data to Azure Storage Emulator running on the same machine as VS 2017 is running on. The emulator's configuration looks like below:

<services>
   <service name="Blob" url="http://127.0.0.1:10000/"/>
   <service name="Queue" url="http://127.0.0.1:10001/"/>
   <service name="Table" url="http://127.0.0.1:10002/"/>
</services>

docker-compose.yml file has the following network definition:

build:
      context: .
      dockerfile: MyWebApi\Dockerfile
      network: host

I am able to view the web api's output at https://127.0.0.1:44315/api/values

Per my understanding, "host" network configuration did its job by assigning the container's host's IP address to the container which seems good so far. The question is that why the dockerized web app in the container fails to communicate with the emulator in spite of the mentioned configuration. What is missing in this exercise?

like image 785
Arash Avatar asked Oct 27 '25 08:10

Arash


1 Answers

As far as I remember, the Azure Storage Emulator is bound in a local-only network configuration and Docker for Windows runs in a VM using Hyper-V.

I'm afraid the solution would be to use the microsoft/azure-storage-emulator image while developing and point your API to it.

Update

You could also try and use host.docker.internal instead of 127.0.0.1 as the host in the connection string (this also might let you use the emulator running on your host instead of the container).

Hope it helps!

like image 104
Itay Podhajcer Avatar answered Oct 29 '25 22:10

Itay Podhajcer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!