Dakota Hipp
Dakota Hipp

Reputation: 809

Cannot reach containers from codebuild

I've been having issue reaching containers from within codebuild. I have an exposed GraphQL service with a downstream auth service and a postgresql database all started through Docker Compose. Running them and testing them works fine locally, however I cannot get the right comination of host names in codebuild.

It looks like my test is able to run if I hit the GraphQL endpoint at 0.0.0.0:8000 however once my GraphQL container attempts to reach the downstream service I will get a connection refused. I've tried reaching the auth service from inside the GraphQL service at auth:8001, 0.0.0.0:8001, with port 8001 exposed, and by setting up a briged network. I am always getting a connection refused error.

I've attached part of my codebuild logs.

Any ideas what I might be missing?

Container 2018/08/28 05:37:17 Running command docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6c4ab1fdc980 docker-compose_graphql "app" 1 second ago Up Less than a second 0.0.0.0:8000->8000/tcp docker-compose_graphql_1 5c665f5f812d docker-compose_auth "/bin/sh -c app" 2 seconds ago Up Less than a second 0.0.0.0:8001->8001/tcp docker-compose_auth_1 b28148784c04 postgres:10.4 "docker-entrypoint..." 2 seconds ago Up 1 second 0.0.0.0:5432->5432/tcp docker-compose_psql_1

Container 2018/08/28 05:37:17 Running command go test ; cd ../..

Register panic: [{"message":"rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = \"transport: Error while dialing dial tcp 0.0.0.0:8001: connect: connection refused\"","path":

Upvotes: 0

Views: 1431

Answers (1)

Dakota Hipp
Dakota Hipp

Reputation: 809

From the "host" machine my exposed GraphQL service could only be reached using the IP address 0.0.0.0. The internal networking was set up correctly and each service could be reached at <NAME>:<PORT> as expected, however, upon error the IP address would be shown (172.27.0.1) instead of the host name.

My problem was that all internal connections were not yet ready, leading to the "connection refused" error. The command sleep 5 after docker-compose up gave my services time to fully initialize before testing.

Upvotes: 2

Related Questions