Hi,

As part of my jenkins pipeline I would like to launch a server in a docker 
image but it seems docker is stopped when/if the last command is put in 
background. How can I fix this? Here is the Jenkinsfile:

node {
    checkout scm
    def backendImage = docker.build("backend-image", "./images/backend")

    sh 'export JENKINS_NODE_COOKIE=dontKillMe'

    backendImage.inside('-p 3000:3000 -p 4000:4000') {

          echo "BUILDING BACKEND"
          echo "----------------"
          echo "STEP1: INSTALLING REQUIREMENTS..."
          sh 'pip install -r requirements.txt'

          echo "STEP2: TESTING..."
          sh 'python test.py'

          echo "STEP3: START PRODUCTION SERVER"

          sh 'export JENKINS_NODE_COOKIE=dontKillMe'
          sh 'nohup python app.py -p 3000 >> app.prod.log &'

    }

}

In above if I remove the & in nohup call the pipeline never finishes but 
the process runs. If I add an & at the end the docker is stopped and 
removed. I see the following in command output:

+ nohup python app.py -p 3000[Pipeline] }$ docker stop --time=1 
e33a650bab7c565148899e28f229a0ec19577b1701227cc89b52752b851a34be
$ docker rm -f e33a650bab7c565148899e28f229a0ec19577b1701227cc89b52752b851a34be



Dockerfile in images/backend is:

FROM python:3.7


MAINTAINER Eser Kandogan "..."


RUN apt-get update -y && \

    apt-get install -y python-pip python-dev

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/9c3c4510-7e8c-44f0-a647-212bcc354ffa%40googlegroups.com.

Reply via email to