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:
OutPut in my Pipeline:
% 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:
curl --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 --:--:-- --:--:-- --:--:-- 0
curl: (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 :)
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 :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.