1

I have a situation with a CI Pipeline I'm trying to implement using Jenkins and Docker .

Inside my pipeline I want to: download a python uwsgi web app, build it in a docker container, run it, then execute API tests against the container's endpoints.

Mentions:

  • I am using a jenkins-docker image ran with docker.sock volume mounted
  • I run the python web app in the docker container, with a volume mounted to docker.sock, so the container mounts on the docker host on the linux server (which also hosts my jenkins docker container)
  • I exposed port 4000 on the python app, I can access the python web app endpoints from the Linux server (curl request), I can access it from the network via browser requests, but I cannot, for the life of me, access the endpoint from the jenkins pipeline

I get the error Failed to connect to 0.0.0.0 port 4000: Connection refused. I also tried with localhost:4000, I get the same result

My pipeline looks like this

node {
def app

stage('Clone repository') {
    git 'https://github.com/....'
}

stage('Build image') {
    app = docker.build('img:tag', '.')
    sh 'docker run -d -p 4000:4000 -v /var/run/docker.sock:/var/run/docker.sock img:tag'
    sleep time: 1, unit: 'MINUTES'
    sh 'curl http://0.0.0.0:4000/api/hello'
}

}

Can anyone please help me with this? Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.