0

I am using pact broker docker image present in

the same image is present in

I am not using docker image of postgresql. I have my own Postgres server hosted in

172.15.16.23 (local ip), port 5432 , admin usaer as pactbrokeruser and password as 'password' and db name is pactbroker-db.

I am setting environment variable as given in the documentation as

  • PACT_BROKER_DATABASE_ADAPTER = postgres
  • PACT_BROKER_DATABASE_USERNAME = pactbrokeruser
  • PACT_BROKER_DATABASE_PASSWORD = password
  • PACT_BROKER_DATABASE_HOST = 172.15.16.23
  • PACT_BROKER_DATABASE_NAME = pactbroker-db

I am using docker run command as

docker run --name pactbroker -e
PACT_BROKER_DATABASE_USERNAME=pactbrokeruser -e
PACT_BROKER_DATABASE_PASSWORD=password -e
PACT_BROKER_DATABASE_ADAPTER=postgres -e PACT_BROKER_DATABASE_HOST= 172.15.16.23 -e PACT_BROKER_DATABASE_NAME=pactbroker_db -p 80:80 dius/pact_broker

but still, the connection is not happening.In docker log, I am getting error "connection has not established" Could you please help me writing proper command of connecting dockerized pact-broker to non-dockerized postgresql. ---------------------------after comment from BEth------------------- I have tried as per your suggestion. BUt environment variables are working fine.I have tried by editing docker compose file given in Git Project https://github.com/DiUS/pact_broker-docker as below

version: '2'

services:

broker_app: image: dius/pact-broker ports: - "80:80" environment: PACT_BROKER_DATABASE_USERNAME: postgres PACT_BROKER_DATABASE_PASSWORD: Welcome123 PACT_BROKER_DATABASE_HOST: 10.0.0.204 PACT_BROKER_DATABASE_NAME: postgres

I have removed database image downloading part as I am using it externally. I have given my external Postgres data base details in the imageenter image description here

So as host I am giving the ip of the server, is it correct?

  • 1
    Check that you can connect to your postgres instance from the docker container manually: `docker exec -it bash` You should then be in a shell, use the CLI to check if you can establish a TCP connection to your postgres instance. Also, it looks as though there is a space after `PACT_BROKER_DATABASE_HOST=`, please check that's not an issue. Lastly, can you please fix the formatting of your post? It's very hard to follow. – Matthew Fellows Aug 05 '17 at 05:39

1 Answers1

0

Can you test that the environment variables are correctly set by running the following command from somewhere that you have the postgres client installed

psql postgresql://${PACT_BROKER_DATABASE_USERNAME}:${PACT_BROKER_DATABASE_PASSWORD}@${PACT_BROKER_DATABASE_HOST}/${PACT_BROKER_DATABASE_NAME}

Can you also check if you have any firewall that might be blocking the connection.

Beth Skurrie
  • 1,333
  • 7
  • 8
  • I have tried but still it is failing. I have updated my main question with my database details and yml file details. PLease let me know if you need anything else. – Shirshendu Saha Aug 05 '17 at 01:34