jenkinsci / jenkinsci/docker-workflow-plugin

[JENKINS-63414] Global Docker agent breaks nested agent usage

Open
#655 9 comments 0 reactions 0 assignees View on GitHub
component:docker-workflow-plugin component:durable-task-plugin imported-jira-issue priority:major resolution:unresolved
Dominant language
Java
Stars
527
Forks
422
Avg merge
10m
Merged PRs (30d)
1

Description

pipeline {

agent none
stages {
stage('parent stage') {
agent {
docker {
image 'ubuntu:bionic'
}
}
stages {
stage('inherited agent') {
steps {
sh 'uname -a'
}
}
stage('explicit agent') {
agent {
node {
label 'master'
}
}
steps {
sh 'uname -a'
}
}
}
}
}
}

The above pipeline results in the following output:

Started by user unknown or anonymous

Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/docker-durable-bug
[Pipeline] {
[Pipeline] stage
[Pipeline] { (parent stage)
[Pipeline] getContext
[Pipeline] isUnix
[Pipeline] sh
+ docker inspect -f . ubuntu:bionic
.
[Pipeline] withDockerContainer
Jenkins does not seem to be running inside a container
$ docker run -t -d -u 982:982 -w /var/lib/jenkins/workspace/docker-durable-bug -v /var/lib/jenkins/workspace/docker-durable-bug:/var/lib/jenkins/workspace/docker-durable-bug:rw,z -v /var/lib/jenkins/workspace/docker-durable-bug@​tmp:/var/lib/jenkins/workspace/docker-durable-bug@​tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** ubuntu:bionic cat
$ docker top c84a4a643ed58929a86d80300821f04249f3e882de21c190043ac475b43eb3f6 -eo pid,comm
[Pipeline] {
[Pipeline] stage
[Pipeline] { (inherited agent)
[Pipeline] sh
+ uname -a
Linux c84a4a643ed5 5.8.1-arch1-1 #1 SMP PREEMPT Wed, 12 Aug 2020 18:50:43 +0000 x86_64 x86_64 x86_64 GNU/Linux
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (explicit agent)
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/docker-durable-bug@​2
[Pipeline] {
[Pipeline] sh
process apparently never started in /var/lib/jenkins/workspace/docker-durable-bug@​2@​tmp/durable-4a02313c
(running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
$ docker stop --time=1 c84a4a643ed58929a86d80300821f04249f3e882de21c190043ac475b43eb3f6
$ docker rm -f c84a4a643ed58929a86d80300821f04249f3e882de21c190043ac475b43eb3f6
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code -2
Finished: FAILURE

If I use a regular agent, rather than a docker one, there's no problem.

The above example works in a clean environment and it is explicitly prepared to reproduce it.

---
Originally reported by smirky, imported from: Global Docker agent breaks nested agent usage


  • status: Open
  • priority: Major
  • component(s): docker-workflow-plugin, durable-task-plugin
  • resolution: Unresolved
  • votes: 5
  • watchers: 11
  • imported: 2025-12-07

Raw content of original issue


pipeline {

agent none
stages {
stage('parent stage') {
agent {
docker {
image 'ubuntu:bionic'
}
}
stages {
stage('inherited agent') {
steps {
sh 'uname -a'
}
}
stage('explicit agent') {
agent {
node {
label 'master'
}
}
steps {
sh 'uname -a'
}
}
}
}
}
}

The above pipeline results in the following output:


Started by user unknown or anonymous

Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/docker-durable-bug
[Pipeline] {
[Pipeline] stage
[Pipeline] { (parent stage)
[Pipeline] getContext
[Pipeline] isUnix
[Pipeline] sh
+ docker inspect -f . ubuntu:bionic
.
[Pipeline] withDockerContainer
Jenkins does not seem to be running inside a container
$ docker run -t -d -u 982:982 -w /var/lib/jenkins/workspace/docker-durable-bug -v /var/lib/jenkins/workspace/docker-durable-bug:/var/lib/jenkins/workspace/docker-durable-bug:rw,z -v /var/lib/jenkins/workspace/docker-durable-bug@tmp:/var/lib/jenkins/workspace/docker-durable-bug@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** ubuntu:bionic cat
$ docker top c84a4a643ed58929a86d80300821f04249f3e882de21c190043ac475b43eb3f6 -eo pid,comm
[Pipeline] {
[Pipeline] stage
[Pipeline] { (inherited agent)
[Pipeline] sh
+ uname -a
Linux c84a4a643ed5 5.8.1-arch1-1 #1 SMP PREEMPT Wed, 12 Aug 2020 18:50:43 +0000 x86_64 x86_64 x86_64 GNU/Linux
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (explicit agent)
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/docker-durable-bug@2
[Pipeline] {
[Pipeline] sh
process apparently never started in /var/lib/jenkins/workspace/docker-durable-bug@2@tmp/durable-4a02313c
(running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
$ docker stop --time=1 c84a4a643ed58929a86d80300821f04249f3e882de21c190043ac475b43eb3f6
$ docker rm -f c84a4a643ed58929a86d80300821f04249f3e882de21c190043ac475b43eb3f6
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code -2
Finished: FAILURE

If I use a regular agent, rather than a docker one, there's no problem.
The above example works in a clean environment and it is explicitly prepared to reproduce it.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.