Hello team!, I'm new on Pact and I'm performing a ...
# pact-broker
a
Hello team!, I'm new on Pact and I'm performing a PoC with Pact. I've created 3 dummy services with Java. I've also used the Pact broker docker image to set up a container in my local. Currently I've been able to generate contracts from the consumer side and publishing into the broker and also verify the providers and publish the verificarion into the broker. At this point I want to play with the Docker Pact CLI (pactfoundation/pact-cli). I couldn't execute any command at this point because a TCP connection error with the pact-broker is raised.
y
depending on your operating system you probably need to point to a docker internal address rather than localhost
and hello my friend!
loving the futurama avatar chefkiss
😊 1
🙌 1
a
I'm using MAC. Yes my broker is running with docker-compose
y
a docker container cannot talk to another container bound on localhost on a mac/windows machine from my exp, and it is documented in Dockers documentation https://docs.docker.com/desktop/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host
If we were to point a link to that guide / workaround where do you think it would best be? In the provider cli?
Hey we couldn't connect to localhost, if you are on a mac/windows try host.docker.internal and see <link to docker docs>
Or somewhere in the docs site / repo readme?
a
This would be very useful, thanks. And also a concrete docker run example using host.docker.internal would be great.
If I try this
Copy code
docker run --rm pactfoundation/pact-cli:latest \
pact-broker list-environments -b=<http://host.docker.internal:9292>
Errno::EADDRNOTAVAIL - Failed to open TCP connection to localhost:443 (Address not available - connect(2) for "localhost" port 443) If I use https I need the credentials but on my docker-compose I'm not using https. https://github.com/alvNa/contract-testing/blob/develop/pact-broker/docker-compose.yml
interesting, that is in our official image. let me a have a test
a
Sure Thanks!
y
So if I comment that out it works fine locally with
Copy code
docker run --rm pactfoundation/pact-cli:latest \
pact-broker list-environments -b=<http://host.docker.internal:9292>
message has been deleted
b
a
Thank you very much for the info. It's working now ! 😃🙌
b
It’s worth learning all the different ways that docker containers are accessible to various hosts. • docker container to docker container within the same docker-compose -> use the service name • native docker host to docker container -> use localhost and the port it’s bound to • independent docker container to another docker container bound to a localhost port -> use host.docker.internal and the port it is bound to
a
Absolutely 👍 Thank you very much!