Could not resolve host mongo, elasticsearch

  docker, docker-swarm, elasticsearch, mongodb

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

  1. sudo docker inspect --format '{{ .HostConfig.NetworkMode }}' container_id All the 3 containers have the default network config
  2. The containers belong to the same security group and all the traffic is open from itself
  3. We experimented with bindIp values
net:
  port: 27017
  bindIp: 127.0.0.1 // Also changed it to 0.0.0.0
  1. 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

LEAVE A COMMENT