I am running into a bit of a road block on some newman tests in a docker container I am running. When I run my tests against a service thats in one of my test envs, it runs fine.
As soon as I run it locally, it fails with the error: connect ECONNREFUSED 127.0.0.1:7000
The only difference I can find here is the explicit port number I am using when running locally.
This only seems to be an issue when its going though the newman docker image. If I remove that from the equation and just use my local newman instance then it works fine.
I am guessing there is something I need to pass in to address this port 7000 issue. Just not able to find a clear answer.
Here is an example of what I am doing:
docker pull postman/newman_ubuntu1404:latest
docker run
-v $PWD/service-test/:/etc/newman postman/newman_ubuntu1404:latest
run “src/test/resources/collection.json”
–environment “test_configs/test.json”
–disable-unicode
–color
–delay-request 100
A docker container by default has a separate network bridge from the host. So when you try to access port 6000 on the localhost from inside the container you get ECONNREFUSED as no application is listening on that port inside the container. There are two ways you can get around this.
Use the host networking in the container - simply pass --network host to the docker run command.
Call the host with its IP address. This is not as straight forward as using the host network stack. You can follow the steps in this blog post to get the host IP inside your container.
Hey @tmccann, you’re correct on the part that specifying a net host doesn’t work as expected in Docker for mac. As an alternative maybe you can go ahead with the second approach as mentioned by @akshaybist and specify the IP address of your host machine.
@debjeetsarkar Definitely need to play around with that a bit and see if I can get it to work as I like.
Where this is with a CI pipeline it could cause some issues but I am sure I can figure it out.
Thx