Cross docker-compose container communication

Hi everyone, I have a rather odd issue where containers running web servers that were created in different docker-compose files CAN “wget” each other on OSX, but not on linux.

Let’s say we have two http services defined in different docker compose files like this:

docker-compose file 1
http-service-1: 8080

docker-compose file 2
http-service-2: 8081

Both containers have a common domain name defined in their hosts file that associates the domain with the host computer IP address, e.g.

192.168.1.10 mydomain.com

If I attach a shell to http-service-1, on OSX this works:

wget http://mydomain.com:8081

However it hangs and doesn’t work on Ubuntu / linux.

It is of note that both docker-compose files create different networks (i.e. they use the default network creation)

So I guess I have a few questions:

Should this work at all? Why does it work on OSX?
What can I do to make it work on Linux.

Also of note, I have verified that if I create a custom network, attach both docker-compose files to that custom network and then use the service names for the wget,

e.g.

wget http://http-service-2:8081

then it works.

Unfortunately I’m not in control of the docker setup (just a consumer of the existing setup). If I have to however, I will recommend a change if the current setup is not best practice.

Thanks in advance!!