Issue with postgre in docker-compose

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

The docker-compose file is the following:

and the travis file is the following:

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 ?

Can’t say for sure without seeing the build.

My crystal ball says that this might be the same as

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.

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).

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

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

Possible reason: According to dns - How to reach docker containers by name instead of IP address? - Stack Overflow, 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.

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.

Imprint