0

am running docker container for pactfoundation/pact-broker:latest

  • on a mac os x (13.2.1).
  • connected to postgres on mac with the right permissions (finally).

Last obstacle: when i try http://0.0.0.0:9292 as from the docker logs (* Listening on http://0.0.0.0:9292), I get "Unable to connect" whether i use firefox, chrome, curl ...

*   Trying 0.0.0.0:9292...
* connect to 0.0.0.0 port 9292 failed: Connection refused
* Failed to connect to 0.0.0.0 port 9292 after 6 ms: Couldn't connect to server
* Closing connection 0
curl: (7) Failed to connect to 0.0.0.0 port 9292 after 6 ms: Couldn't connect to server

I get the same result with any version of localhost, 127.0.0.1, ...

I know macs can be a pain for connection, so i span up a local fastify server and checked it was reachable, and a docker dynamodb instance and checked its reachable, ....

I could do with a next thing to try, or else a sage word from someone on what I may have not done or missed...

user2320340
  • 41
  • 1
  • 7
  • show us the command you used to run the container – erik258 Mar 28 '23 at 16:11
  • I am running it from docker desktop with params: ```PACT_BROKER_DATABASE_URL = postgres://pact_broker:{pwd}@docker.for.mac.localhost/pact_broker``` and just out of frustration (because i failed to connect) added the port for the docker (but still at 9292): ```PACT_BROKER_PORT = 9292``` – user2320340 Mar 29 '23 at 13:58
  • sounds like pact is in one docker container, postgres in another. They will each have their own `localhost`, and won't use the mac's. https://docs.docker.com/network/network-tutorial-standalone/ you might also consider looking at docker-compose which can simplify running multiple containers https://docs.docker.com/compose/ – erik258 Mar 29 '23 at 19:50
  • Actually postgres in on the Mac not in a container, but using docker.for.mac.localhost got it connected (found that in another stack overflow post). I will take a look at the links you suggested though (did read through the docker compose option in pact foundation readme) – user2320340 Mar 30 '23 at 07:15

1 Answers1

1

ok - found a command line option from stackoverflow azure pactbroker docker connect question

docker run -e PACT_BROKER_DATABASE_USERNAME=pact_broker \
-e PACT_BROKER_DATABASE_URL=postgres://pact_broker:$password@docker.for.mac.localhost/pact_broker \
-e PACT_BROKER_DATABASE_NAME=pact_broker \
-e PACT_BROKER_DATABASE_PORT=5432 \
-p 9292:9292 \
pactfoundation/pact-broker:latest

This has things up and running fine. Will have a further read, try adding some settings in docker desktop to see where it didnt work (if i find that will add it here to tie things off), and then follow @erik258 advice on docker compose...

user2320340
  • 41
  • 1
  • 7