0

I am using custom docker container to build code, the container is integrated with Amazon codebuild. AWS codebuild spins up a Docker container and builds the code on the container provided by us. The Dockerfile of container that I've written is like this -> Dockerfile

The Docker container is supposed to have Java-8, Gradle-4.7 and Postgres-10 installed on it.

I run the Docker container on the local machine and can see Postgres service running. However, on AWS codebuild, the docker container does not start the Postgres server. I tried to know the status of Postgres using commands in buildspec.yml file and found out it is down.

Following is the error I can see in the cloudwatch logs -

May 18, 2018 9:26:33 AM org.postgresql.Driver connect
SEVERE: Connection error: 
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

Does anyone have any idea about this? Is the Dockerfile correct?

Jeevan Patil
  • 6,029
  • 3
  • 33
  • 50
  • is this helpful https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach – moha297 May 21 '18 at 15:47

1 Answers1

0

The problem might actually be entrypoint (in the Dockerfile you mentioned).

CodeBuild would override the entrypoint on each run which would be different than what you would see with your local docker run (you can also test this behavior with codebuild local agent)

"ENTRYPOINT ["/etc/init.d/postgresql", "start"]"

Can you post your buildspec.yml file? Simple fix for this would be to run the entrypoint command as part of your buildspec.yml

awsnitin
  • 626
  • 3
  • 6