We created a docker swarm for 2 containers, mongo (alias mongo), ES (alias elasticsearch). Because of the unique use case our application is not part of the swarm but it still on bridge/default
network. We want to reach out to mongo & ES from our app but we face the error
[email protected]:~/project$ curl -XGET http://mongo:27017
curl: (6) Could not resolve host: mongo
We are using the independent images available from mongo and ES.
These are the things we verified
sudo docker inspect --format '{{ .HostConfig.NetworkMode }}' container_id
All the 3 containers have thedefault
network config- The containers belong to the same security group and all the traffic is open from itself
- We experimented with bindIp values
net:
port: 27017
bindIp: 127.0.0.1 // Also changed it to 0.0.0.0
- We curled to
google.com
and it worked so shouldn’t be a dns issue
Any pointers what else we could try to get to the bottom of this?
Source: Docker Questions