Linking containers during run

docker

#1

Hi,

I must be missing something here…
Say I have a container alambic_test which needs access to a postgres container named ‘postgres’. Db requests from alambic_test look for a host named ‘postgres’. It works fine in docker-compose thanks to the container_name command, but I cannot make it work with jet locally since jet names the container differently (and I can find no way to set the container name in the steps or services file).

How do you do guys to connect to other containers during your test runs?

Any idea?

Thanks,


boris


#2

Hey Boris,

if you configure your codeship-services.yml file like the one mentioned on https://documentation.codeship.com/pro/getting-started/getting-started/#define-your-services--compose-file this should work via the jet CLI as well.

If it doesn’t, could you let me know which version of the jet CLI and Docker you’re using, as well as which OS you are running? Sharing a sample services and steps file might help reproduce this as well.


#3

Hi Marko,

Thanks for your quick answer. I followed the tutorial and spent some time doing various tests, of course, but I’m still missing something…

The incriminated build is at
https://app.codeship.com/projects/189806/builds/d7811234-20b6-4c0b-aa15-33f4dc04a406

When I run it (alambic_test step) I get the following log (I execute psql to initialise the db in the called script):

--8<------------------------------------------------
2017-02-14T12:19:37.002Zalambic_test_buildpsql: could not connect to server: Connection refused
2017-02-14T12:19:37.002Zalambic_test_build	Is the server running on host "postgres" (172.17.0.3) and accepting
2017-02-14T12:19:37.002Zalambic_test_build	TCP/IP connections on port 5432?
--8<------------------------------------------------

I solved this in docker-compose by using the container_name directive, which is not supported by the codeship file.

Please let me know if more information is required. Thanks a lot for any advice/help!


boris


#4

Are you using a script to wait for the database server to get ready? Something like the script mentioned on https://documentation.codeship.com/pro/getting-started/services-and-databases/#waiting-for-a-service-to-start?


#5

I’m sleeping for 10 seconds, which is a bit crude but very efficient. :slight_smile:
I’d like to enphasise however that I don’t think it’s a db-not-really-yet problem; the log explicitly states that the postgres host is not found. Am I misled?

Thanks,


boris


#6

Oh and I realise I didn’t tell you the versions of sw used…
On my local host:

boris@midkemia ~ $ jet version
1.16.0
boris@midkemia ~ $ docker --version
Docker version 1.13.1, build 092cba3


boris


#7

Thanks for the versions, they all look fine.

As for the logs, I didn’t see any reference to the host not being found (at least on https://app.codeship.com/projects/189806/builds/d7811234-20b6-4c0b-aa15-33f4dc04a406), the only error I see is the connection refused, which usually indicates that the server is not ready yet.

You could test by pinging the postgres container though.