Pipeline docker exec curl - (7) Failed to connect: Connection refused

Hi everyone,

after researching and trying out different things I still have two different errors so I hope someone of you can help me.

I try to execute a curl command inside a running Docker container in my bitbucket pipeline. I wanna check if the node server is running correctly and the login site has a get 200.

 

Parts of my bitbucket-pipelines.yml

options: docker: true
pipelines:
branches:
master:
-
step:
name: build app
caches: - node
script:
-
export IMAGE_NAME_APP=$DOCKER_USER/client:$BITBUCKET_COMMIT
# authenticate with the Docker Hub registry
-
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
# pull docker mongodb image and start it
-
docker pull $DOCKER_USER/mongodb:latest
-
docker pull $DOCKER_USER/client:latest
-
docker run -d -p 27017:27017 --name mongodb -i $DOCKER_USER/mongodb:latest
-
docker ps
-
docker run -d --env-file=docker.env -p 3001:3001 --name client --link mongodb:mongodb -i $DOCKER_USER/client:latest
-
docker ps

- docker exec -i client curl -I 0.0.0.0:3001/signin/ | head -n 1 | grep "HTTP/1.[01] [23].."

 

Both container running and now I wanted to check if the website is running inside the container with a curl statement but It's not working. I tried the same commands locally and it works. I also switched already between IP address like 127.0.0.1 and 0.0.0.0 --> both did not work in the pipeline but locally 

docker ps output:

Bildschirmfoto 2018-01-19 um 11.18.45.png

OutPut in my Pipeline:

Bildschirmfoto 2018-01-19 um 11.20.25.png

% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:--

0curl: (7) Failed to connect to 0.0.0.0 port 3001: Connection refused

 

try with curl command directly in the shell

I also tried to execute the curl command directly in the pipeline shell but then I also have an error, but a different one:

Bildschirmfoto 2018-01-19 um 11.19.29.pngcurl --head http://127.0.0.1:3001/signin/ | head -n 1 | grep "HTTP/1.[01] [23].." % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (56) Recv failure: Connection reset by peer

 

Maybe someone of you have an idea how to solve that issue. My bitbucket-pipelines.yml is sligthly changed for here and it's also pulling instead of building the image currently to speed up the feedback from the pipeline.

 

Thanks you all so much for reading this and helping me. Wish you all a great day :)

 

1 answer

1 accepted

The solution for running the curl command directly in the container, exchange IP address against localhost :

docker exec -i client curl -I localhost:3001/signin/ | head -n 1 | grep "HTTP/1.[01] [23].."

works now :)

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

714 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot