I receive a "No Such Container" error while trying to run my build in a Jenkins declarative pipeline. It is a Docker-in-Docker setup but I don't have issues running other stages of the pipeline. This problem began happening when I created a shared library and moved some of the code into this library. I've included the relevant pipeline stage and the test code for the shared library.
I have tried removing the docker block from the agent section and the shared library test code works so I know this is somehow related to Docker-in-Docker. Any help on how to debug this further or other tips would be greatly appreciated.
Jenkins Console Log
Status: Downloaded newer image for <redacted>/alpine-tools:3.12
[Pipeline] withDockerContainer
docker-1365477f6a6210 on <redacted>-swarm-lon02 seems to be running inside container 1948d9ca656dce596c4df9c27687978677b76969d3db76bac30ef985321e1cbb
but /home/jenkins/workspace/_<redacted>_jenkins-ETDAR3LXDVCPZD7IMTPE244P7DI3KIALGXBFQ3LOTB3VZFVBJLDA could not be found among []
but /home/jenkins/workspace/_<redacted>_jenkins-ETDAR3LXDVCPZD7IMTPE244P7DI3KIALGXBFQ3LOTB3VZFVBJLDA@tmp could not be found among []
$ docker run -t -d -u 1000:1000 -u root -w /home/jenkins/workspace/_<redacted>_jenkins-ETDAR3LXDVCPZD7IMTPE244P7DI3KIALGXBFQ3LOTB3VZFVBJLDA -v /home/jenkins/workspace/_<redacted>_jenkins-ETDAR3LXDVCPZD7IMTPE244P7DI3KIALGXBFQ3LOTB3VZFVBJLDA:/home/jenkins/workspace/_<redacted>_jenkins-ETDAR3LXDVCPZD7IMTPE244P7DI3KIALGXBFQ3LOTB3VZFVBJLDA:rw,z -v /home/jenkins/workspace/_<redacted>_jenkins-ETDAR3LXDVCPZD7IMTPE244P7DI3KIALGXBFQ3LOTB3VZFVBJLDA@tmp:/home/jenkins/workspace/_<redacted>_jenkins-ETDAR3LXDVCPZD7IMTPE244P7DI3KIALGXBFQ3LOTB3VZFVBJLDA@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 ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** <redacted>/alpine-tools:3.12 cat
$ docker top 84284972066c3cae9c5f8482beaabdc4146f22e4877b0323814f7d377c8babc2 -eo pid,comm
[Pipeline] {
[Pipeline] script
[Pipeline] {
[Pipeline] node
Running on docker-13654f88a1b20d on <redacted>-swarm-lon02 in /home/jenkins/workspace/_<redacted>_jenkins-ETDAR3LXDVCPZD7IMTPE244P7DI3KIALGXBFQ3LOTB3VZFVBJLDA
[Pipeline] {
[Pipeline] sh
[_<redacted>_jenkins-ETDAR3LXDVCPZD7IMTPE244P7DI3KIALGXBFQ3LOTB3VZFVBJLDA] Running shell script
Error: No such container: 84284972066c3cae9c5f8482beaabdc4146f22e4877b0323814f7d377c8babc2 *** HERE ***
process apparently never started in /home/jenkins/workspace/_<redacted>_jenkins-ETDAR3LXDVCPZD7IMTPE244P7DI3KIALGXBFQ3LOTB3VZFVBJLDA@tmp/durable-03c48bbd
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // script
[Pipeline] }
$ docker stop --time=1 84284972066c3cae9c5f8482beaabdc4146f22e4877b0323814f7d377c8babc2
$ docker rm -f 84284972066c3cae9c5f8482beaabdc4146f22e4877b0323814f7d377c8babc2
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // withDockerRegistry
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] End of Pipeline
ERROR: script returned exit code -2
Finished: FAILURE
Jenkins Shared Library
Filename: deployApp.groovy
def call(Map config) {
node {
sh 'echo SUCCESS'
}
}
Jenkins Pipeline Stage
stage('Deploy') {
agent {
docker {
registryCredentialsId '<redacted>'
registryUrl '<redacted>'
image '<redacted>/alpine-tools:3.12'
args '-u root'
}
}
when {
beforeAgent true
expression { env.BRANCH_NAME ==~ /(master|release|jenkins)/ }
}
steps {
script {
deployApp deploy:true
}
}
}