I'm having issues when using volumes and postgres.
The error is: could not translate host name "postgres" to address: Name or service not known
My config files: https://gist.github.com/mfbmina/5defa6f610d9818e3d4dc666ff55cc06
Docker version: Docker version 17.06.0-ce, build 02c1d87
docker-compose version: docker-compose version 1.15.0, build unknown
OS: macOS Sierra, 10.12.6
When I remove volumes
from docker-compose.yml
it works fine, but do not persists my data.
Hey @shin- , I don't know how this article can help me.
Your app assumes that it will always be able to immediately discover and connect to the database. The article I linked explains why that's a bad assumption and what can/should be done to fix it.
@shin sorry for bringing this issue again one year later, but this is biting here. In our case the database starts first, the web app depends on database in docker-compose. And everything works for a while, but a few minutes after starting the webapp just cannot resolve the host name.
The webapp and DB are running on different machines via Rancher, that uses Docker-compose. We have a bunch of instances of this system but looks like only a few are showing this behavior.
Connection issues are not really in the realm of Compose. You probably want to report this on the Rancher repo.
Ops, sorry about that. Gonna do that. Thanks!
Most helpful comment
Read this: https://docs.docker.com/compose/startup-order/