I have 2 Windows containers and 2 Linux containers that I am trying to make work together on Docker Desktop. I have separate compose files for both, and when I "compose up" both (using the "Switch to Windows/Linux containers..." in between), they can communicate using the internal IP addresses they got. However, when I try to use the service names of the compose files, they can't find each other.
I have tried anything I could think of with respect to the networking:
part of compose files, to try and get them in the same network :
- use the same network name in both compose files
- use the same network name in both, but declare one
external
- custom names, with and without using
default
andexternal
(basically, I tried everything mentioned in this Stackoverflow question)
As also mentioned in this question, there seems to be no way for the Windows context to see the Linux context. If one side has the network external
, you get an error that the network is unknown. If both define the same network name (not using external
), then they still don't see each other.
The two sample compose files below illustrate the issue. linuxservice
and nodered
can't reference winservice
, but can reach that container on it's internal IP address. Trying localhost:9340 from nodered
also didn't work, and resulted in a 'connection refused' error.
Compose file for my Linux containers:
version: "3.7"
services:
linuxservice:
image: myregistry/mycontainer:development
ports:
- 8080:8080
nodered:
image: nodered/node-red
ports:
- 1880:1880
volumes:
- 'C:/data/Docker/nr-volume:/data'
networks:
default:
name: docker-net
Compose file for my Windows containers:
version: '3.1'
services:
windb:
image: myregistry/olmysql:v2
ports:
- 3306:3306
winservice:
image: myregistry/connect:latest
ports:
- 9340:9340
depends_on:
- windb
networks:
default:
name: docker-net
Is there any way these can containers can be made to communicate by name instead of by IP address?
Assuming there is no way to get them in one network, would it be possible to create some kind of DNS in either network that works across the two networks? Or is there a way to allow them to use localhost:9340
?