# Issue with postgre in docker-compose

**URL:** <https://travis-ci.community/t/issue-with-postgre-in-docker-compose/7279>\
**Category:** Travis CI Discussions & Feedback\
**Created:** [February 19, 2020, 2:03pm UTC](https://travis-ci.community/t/issue-with-postgre-in-docker-compose/7279 "2020-02-19T14:03:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![DerouineauNicolas](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@DerouineauNicolas](https://travis-ci.community/u/DerouineauNicolas)\
**Post date:** [February 19, 2020, 2:03pm UTC](https://travis-ci.community/t/issue-with-postgre-in-docker-compose/7279/1 "2020-02-19T14:03:27Z")

</div>

Hi,  
We are using postgre as a service in a docker-compose file.

The docker-compose file is the following:

> <https://github.com/Web-Multi-Media/HttpStreamingServer/blob/test3/docker-compose-prod.yml>

and the travis file is the following:

> <https://github.com/Web-Multi-Media/HttpStreamingServer/blob/test3/.travis.yml>

As you can see, we are using the wait-for-it.sh script to wait for postgree to be up before performing tests.  
Until recently, this method was functionning but starting from the recent days, we are getting the following error:

```
File "/usr/local/lib/python3.6/dist-packages/psycopg2/ __init__.py", line 130, in connect

conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: could not translate host name "db" to address: Name or service not known

The command "docker-compose -f docker-compose-prod.yml run --service-ports --rm web ./wait-for-it.sh db:5432 -- python3 manage.py test" exited with 1.

```

Any suggestions on what could be causing this issue ? Any change in Travis CI we should be aware of ?

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [February 20, 2020, 1:06am UTC](https://travis-ci.community/t/issue-with-postgre-in-docker-compose/7279/2 "2020-02-20T01:06:31Z")

</div>

Can’t say for sure without seeing the build.

My crystal ball says that this might be the same as

> [@"No route to host" trying to connect to Docker container at 172.17.0.2](https://travis-ci.community/t/abuse-detected-while-debugging-docker-on-travis/7066/2):
>
> AFAICS searching [https://docs.docker.com](https://docs.docker.com), the 1st container having 172.17.0.2 is not a guarantee, and neither is it a guarantee that that address is accessible from the host. [Container networking | Docker Documentation](https://docs.docker.com/config/containers/container-networking/) mentions that the default bridge is deliberately protected with iptables rules and suggests connecting to containers from the outside via published ports.

---

<div class="post-metadata">

**Author:** ![DerouineauNicolas](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@DerouineauNicolas](https://travis-ci.community/u/DerouineauNicolas)\
**Post date:** [February 20, 2020, 9:04am UTC](https://travis-ci.community/t/issue-with-postgre-in-docker-compose/7279/3 "2020-02-20T09:04:36Z")

</div>

Thanks for your answer but I think our issue is different.

You can see the failing build here [https://travis-ci.org/Web-Multi-Media/HttpStreamingServer/builds/652490849](https://travis-ci.org/Web-Multi-Media/HttpStreamingServer/builds/652490849).

The thing is we are using the “dns” provided by docker-compose to reach our database (ie: we are connecting to a hostname called db, not a hardcoded IP adress).

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [February 20, 2020, 4:43pm UTC](https://travis-ci.community/t/issue-with-postgre-in-docker-compose/7279/4 "2020-02-20T16:43:43Z")

</div>

In the build you’ve shown, the error is completely different.

---

<div class="post-metadata">

**Author:** ![DerouineauNicolas](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@DerouineauNicolas](https://travis-ci.community/u/DerouineauNicolas)\
**Post date:** [February 21, 2020, 9:42am UTC](https://travis-ci.community/t/issue-with-postgre-in-docker-compose/7279/5 "2020-02-21T09:42:19Z")

</div>

I’m sorry, please find the correct failing build here ([https://travis-ci.org/Web-Multi-Media/HttpStreamingServer/builds/653371168](https://travis-ci.org/Web-Multi-Media/HttpStreamingServer/builds/653371168))

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [February 22, 2020, 9:21am UTC](https://travis-ci.community/t/issue-with-postgre-in-docker-compose/7279/6 "2020-02-22T09:21:52Z")

</div>

Possible reason: According to [dns - How to reach docker containers by name instead of IP address? - Stack Overflow](https://stackoverflow.com/questions/31149501/how-to-reach-docker-containers-by-name-instead-of-ip-address), Docker Compose adds prefixes to container names unless you specify container names manually.

I suggest using Docker utility commands to find out what is running and with what network configuration.

---

<div class="post-metadata">

**Author:** ![DerouineauNicolas](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@DerouineauNicolas](https://travis-ci.community/u/DerouineauNicolas)\
**Post date:** [February 24, 2020, 4:33pm UTC](https://travis-ci.community/t/issue-with-postgre-in-docker-compose/7279/7 "2020-02-24T16:33:12Z")

</div>

Thanks for your help. After checking the different services status, we figured out that the postgres:9.6 image has been updated and that this new version require a mendatory password at start time. This was the reason why the database was not up.
