Connect Windows container to Linux container running on same Docker host
Originally asked on ServerFault since I think this is a networking question, but was told to move here: https://serverfault.com/questions/844480/connect-windows-container-to-linux-container-running-on-same-docker-host
I have RabbitMQ running in a Linux container and I want to connect to it from a Windows container, both containers are running on the same host, a Windows 10 PC.
I start RabbitMQ like this:
docker run -p 8080:15672 -p 5672:5672 -d --hostname my-rabbit --name some-rabbit rabbitmq:3-management
I’m able to view RabbitMQ’s web management app from the host PC here:
I switch to Windows container mode (using the little Whale icon) and start my Windows container like so:
docker run --name "whatever" -d "whatever"
At this point I can connect to RabbitMQ by using the default gateway IP assigned to the Windows container. My connection string looks like this:
Works fine, but I prefer to use hostnames, and also not tunnel through the host if I can avoid it (I had to add a firewall exception to make this work). For talking between my various Windows containers I can use hostnames if I run each container with a unique –hostname value, but that does not appear to work across Windows and Linux containers. I tried adding a new network to my Linux containers with the same subnet as the Windows containers, but that did not help.
I’ve read a little about swarms and other more advanced/newer options, but currently I’m focusing on all of my containers running on one host (this is for QA efforts, not production). I want to make it as easy as possible for SDETs and others to pull down multiple containers, run a couple BAT files or PowerShell scripts and have everything talking nicely — without modifying IP addresses in config files, or worrying about conflicting networking setups. Pretty much what I can easily do if I was only using Linux containers, or only using Windows containers, but I need to use both.