We had a Jenkins build system, using the Groovy DSL, that worked well for us.

But then we recently hired a new developer who is supposed to be very good. He decided to rewrite the way our tests work. We are now trying to make our build process adjust to his new ideas. We have a Python app. Previously, our build system went something like this:

git pull

run tests

if good, then push to ECR


But he pulled all the tests into a separate container. So now I need to do something like:

  1. 'docker build' the main app

  2. 'docker run' the main app

  3. 'docker build' the test app

  4. 'docker run' the test app (this fires HTTP requests at the main app)

  5. get results from test app

  6. shut down main app

  7. if test results good, push to ECR

But when I call 'docker run' on the main app, it just runs forever. It's a Python web app, Django, with Gunicorn serving the web requests.

So, what do I do here? Should I spin the main app up in a separate thread, perhaps with a time to automatically kill it after a certain amount of time?

  • You can use docker compose to automatically build and spin up all the containers – ALex_hha Jul 26 '18 at 20:49
  • Oh? In what sense? – JeffGallant Jul 27 '18 at 17:34

Are you running docker run -d ... with the -d parameter to detach from the container? Could that be the problem?


I think you'll find you have to run docker run -d to detach from the container, otherwise it will just stay on the first container showing STDOUT until Jenkins kills the container when it stops the job. I'd just run them and give them a name, and then at the end of the Jenkins job, stop and remove all containers with that name.


docker run -d --name jenkins-main-app main-app 
docker run -d --name jenkins-test-app test-app 

Then at the end:

docker stop --name jenkins-main-app
docker stop --name jenkins-test-app
docker rm --name jenkins-main-app
docker rm --name jenkins-test-app

Hope that helps.

  • 1
    No. That is a possible solution, though then I have to kill the container later. But I suppose that is not such a problem. – JeffGallant Jul 26 '18 at 16:12
  • Ok, I'll add more things that have helped me into the main answer above. – David Birks Jul 26 '18 at 17:23

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.