Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Docker Pipeline Exit Code -1

We have a Jenkinsfile that uses the docker plugin to run a script inside a given container. This works fine for some images, but fails immediately with a -1 exit code on others. We've reduced the error down to a simple sleep. This is the Jenkinsfile:

node("docker") {
    def wheezy_image = docker.image("pyca/cryptography-runner-wheezy")
    wheezy_image.pull()
    wheezy_image.inside {
        sh """sleep 120"""
    }
}

And here's the jenkins output

+ docker pull pyca/cryptography-runner-wheezy
Using default tag: latest
latest: Pulling from pyca/cryptography-runner-wheezy
Digest: sha256:ff5d9f661b05d831ace3811eec9f034fed7994279ff2307695a2cb7c32d6fa11
Status: Image is up to date for pyca/cryptography-runner-wheezy:latest
[Pipeline] sh
[3525-VE2ETALXLYB7VN3] Running shell script
+ docker inspect -f . pyca/cryptography-runner-wheezy
.
[Pipeline] withDockerContainer
$ docker run -t -d -u 1000:1000 -w /var/jenkins_home/workspace/3525-VE2ETALXLYB7VN3 --volumes-from 1382a2e208dd5575acd26f11678855282fc854319096de60cef6818ea279f25f -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** --entrypoint cat pyca/cryptography-runner-wheezy
[Pipeline] {
[Pipeline] sh
[3525-VE2ETALXLYB7VN3] Running shell script
+ sleep 120
[Pipeline] }
$ docker stop --time=1 887db8989e03a10dd89132b1ac6e18261ee4a49e6afe8b0c5568326b6c023654
$ docker rm -f 887db8989e03a10dd89132b1ac6e18261ee4a49e6afe8b0c5568326b6c023654
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline

GitHub has been notified of this commit’s build result

ERROR: script returned exit code -1
Finished: FAILURE

Interestingly, if the sleep is less than 1 second then this passes (but the 120 second sleep works just fine on many of the other images).

For reference, here is a jessie image that works, and a wheezy image that does not.

Does anyone know what might be going on here?

like image 692
Paul Kehrer Avatar asked May 07 '17 18:05

Paul Kehrer


People also ask

How do you exit a docker container?

To exit out of the docker container bash shell. Just run exit or hit ctrl-D like you normally would.

How do I exit docker without stopping?

Docker supports a keyboard combination to gracefully detach from a container. Press Ctrl-P, followed by Ctrl-Q, to detach from your connection. You'll be dropped back into your shell but the previously attached process will remain alive, keeping your container running.


1 Answers

Looks to be related to your image not having ps installed. I just took the debian base and was able to replicate that it wouldn't work. Installed ps, and it did work. You can also use the withRun function and it works. Here's my Jenkinsfile:

node("docker") {

    // Weezy that also ran... apt-get update && apt-get install -y procps
    def wheezy_image = docker.image("smalone/weezy-ps-test")
    wheezy_image.pull()
    wheezy_image.inside {
       sh 'sleep 2'
    }

      // Base image for weezy-ps-test that has no ps installed using withRun() instead of inside()
    wheezy_image = docker.image("debian:wheezy")
    wheezy_image.pull()
    wheezy_image.withRun { c ->
       sh 'sleep 2'
    }

    // Base image for weezy-ps-test that has no ps installed
    wheezy_image = docker.image("debian:wheezy")
    wheezy_image.pull()
    wheezy_image.inside {
       sh 'sleep 2'
    }
}

I'll open a ticket on the docker pipeline plugin, if one doesn't exist.

EDIT: There was a ticket open, but they hadn't found the root cause yet. See: https://issues.jenkins-ci.org/browse/JENKINS-40101 to track the status of this issue!

like image 123
Spencer Malone Avatar answered Oct 19 '22 00:10

Spencer Malone