1

I'm trying to set up development environment for a project using Visual Studio Docker Tools.

I have a bunch of .net core based and few full fx microservices which are communicating through RabbitMq. RabbitMq is inside of a linux based docker container and so does .net core microservices, and they are connected to the same network in docker-compose file. .Net core microservices have no trouble with connecting to RabbitMq by using container name as a hostname.

But when it comes to windows based containers there is a problem that network is not shared between windows and linux docker engines, so I can't connect windows based microservices to the RabbitMq service by using container name (using host IP would be weak for development machine, because it will be different for other developer and will bring some configuration overhead).

AFAIK swarm mode can be used to ensure such communication, but that is more suited for test/prod environments than for development, and also that cool Visual Studio container debug feature will be lost in that case (it runs docker-compose up command).

So what is the best way for mixed-system intercontainer communication on a single host?

liri2006
  • 591
  • 7
  • 18
  • 2
    I didn't realise you *could* run Linux and Windows containers on a single machine. Could you create a `hosts` file where the IP of the RabbitMQ docker container is set to a name? For example, with Docker Toolbox you could put the following in `hosts`: 192.168.99.100 docker Then each developer could set the IP and the docker-compose could use the name. – Boggin Aug 08 '17 at 10:04
  • Trick with hosts file works. It still requires some pre-configuration, but it is much better than hardcoding IPs. If nothing native will pop up, I'll go with this. Thanx! – liri2006 Aug 08 '17 at 19:51
  • There are SO Q&As that say you can't mix Linux and Windows Docker Engines on the same machine: [Can I mix linux-based and windows-based containers in same docker engine host?](https://stackoverflow.com/q/41010604/444244) Perhaps you could update them with your strategy? – Boggin Aug 08 '17 at 20:52
  • I think that question relates to production setup with windows containers (AKA "Docker On Windows"). And I'm just using "Docker for Windows" on my development machine where you can switch between windows and linux engines manually with tray icon or powershell script (containers just continue to run after the switch). – liri2006 Aug 09 '17 at 08:57

1 Answers1

2

Create a hosts file where the IP of the RabbitMQ Docker container is set to a name. For example, with Docker Toolbox you could put the following in hosts: 192.168.99.100 docker Then each developer could set the IP and the docker-compose could use the name.

Boggin
  • 3,251
  • 3
  • 33
  • 48