withDockerContainer in pipeline failing

2,023 views
Skip to first unread message

Jeeva Chelladhurai

unread,
Jun 27, 2018, 3:55:07 AM6/27/18
to Jenkins Users
Hello All,

I am running Jenkins (2.121.1) inside a Docker container and I use ssh node as build nodes. I want to use  withDockerContainer in my pipeline as shown in /1/ and getting an error as shown in /2/. Could you please help me to resolve this issue?

/1/
pipeline {
    agent { label "build" }   
    stages {
        stage("test") {
            steps {
                withDockerContainer (image: 'busybox') {    
                         sh 'pwd'
                }

            }
        }
    }
}

/2/
Started by user Jeeva S. Chelladhurai
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on build-server in /home/ubuntu/workspace/sandbox/withdocker
[Pipeline] {
[Pipeline] stage
[Pipeline] { (test)
[Pipeline] withDockerContainer
build-server does not seem to be running inside a container
$ docker run -t -d -u 1000:1000 -w /home/ubuntu/workspace/sandbox/withdocker -v /home/ubuntu/workspace/sandbox/withdocker:/home/ubuntu/workspace/sandbox/withdocker:rw,z -v /home/ubuntu/workspace/sandbox/withdocker@tmp:/home/ubuntu/workspace/sandbox/withdocker@tmp:rw,z -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 ******** -e ******** busybox cat
$ docker top 661025c3ef5f46681fd3f9c73c8e0522c7dbcbbf35d8531aab0aa4739d5ee840 -eo pid,comm
[Pipeline] {
[Pipeline] sh
[withdocker] Running shell script
invalid argument "=" for "-e, --env" flag: invalid environment variable: =
See 'docker exec --help'.
process apparently never started in /home/ubuntu/workspace/sandbox/withdocker@tmp/durable-a265513a
[Pipeline] }
$ docker stop --time=1 661025c3ef5f46681fd3f9c73c8e0522c7dbcbbf35d8531aab0aa4739d5ee840
$ docker rm -f 661025c3ef5f46681fd3f9c73c8e0522c7dbcbbf35d8531aab0aa4739d5ee840
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code -2
Finished: FAILURE

Bernardo Vale

unread,
Jun 27, 2018, 9:37:13 AM6/27/18
to jenkins...@googlegroups.com
I had this error couple of weeks ago. Go to global configuration, there is probably an empty environment variable declared.

--
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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/aeaab9d7-8b08-49b2-b54d-5ce56c34ebf6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jeeva Chelladhurai

unread,
Jun 27, 2018, 2:44:32 PM6/27/18
to Jenkins Users
Thanks! it worked!!

NARASIMHAMURTHY G N

unread,
Jun 25, 2019, 5:52:51 PM6/25/19
to Jenkins Users
Hi  All,

i have  also facing Jenkins Deployment issue. could you possible to help me to this issue, this error is looks similar to about error.
Please look at below errors.

JENKINS-33510: working directory will be /home/ubuntu/workspace/pa-service_feature_ABPA-1274-ETE not /home/ubuntu/workspace/pa-service_feature_ABPA-1274-ETE@2

Error: No such container: 2baff9ea9dedde01706ed9a77c233a233cfc2f9693227e807e1e2f5914932251

process apparently never started in /home/ubuntu/workspace/pa-service_feature_ABPA-1274-ETE@2@tmp/durable-a0339ab6

script returned exit code -2

Ted Kossoko

unread,
Jul 26, 2019, 3:22:02 PM7/26/19
to Jenkins Users
Hi, did you find a solution ? I'm facing the same problem. How did you correct it ?

Ivan Fernandez Calvo

unread,
Jul 27, 2019, 12:18:19 PM7/27/19
to Jenkins Users
hi,

I've never used `withDockerContainer`,   if you take a look to the documentation you'd see the way to run commands inside a docker container in pipeline https://jenkins.io/doc/book/pipeline/docker/ this is the same code that was in this email thread

pipeline {
  agent {
    label "build"
  }
  stages {
    stage("test") {
      steps {
        script {
          docker.inside(image: 'busybox') {
            sh 'pwd'
          }
        }
      }
    }
  }
}
Reply all
Reply to author
Forward
0 new messages