Docker Community Forums

Share and learn in the Docker community.

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.

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


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,


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!!

I don’t exactly why !!! But finally, this works for me:

version: ‘3.5’

container_name: gateway
context: …/robots-store-gateway
dockerfile: Dockerfile
image: robots-store-gateway
- 8000:8000
hostname: gateway
eureka.client.serviceUrl.defaultZone: http://serviceregistry:8761/eureka/

container_name: serviceregistry
context: …/robots-sotre-serviceregistry
image: robots-sotre-serviceregistry
- 8761:8761
hostname: serviceregistry
eureka.client.serviceUrl.defaultZone: http://serviceregistry:8761/eureka/