On 26 February 2018 at 03:10, nicolas de loof <nicolas.del...@gmail.com> wrote: > docker support in declarative pipeline relies on docker-workfow plugin, > which require the jenkins slave to have access to a LOCAL docker daemon, > which means the docker agent you are provisioning on computer B using docker > plugin HAS to be configured with /var/run/docker.sock (so, the one from B) > bind mounted. Doing so it can then create some side container to host the > build steps.
Hi Nicolas, Thanks for the tips, i think i'm getting there, but i'm still missing some bits: - I have created a docker image based on jenkinsci/jnlp-slave, the only customisation is installing docker in it - The pipeline now get checkout inside tmy slave (on machine B) - The docker image from the Jenkinsfile is pulled and executed. But i get this weird error (see full log at the end of this email): ------------------------ docker-44734997459c on work-leader seems to be running inside container e7f7a4381e32c456b806695b9b7334751d88f1a3985867bb964e9fd3d2e8c948 but /home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q could not be found among [/home/jenkins/.jenkins, /home/jenkins/agent] but /home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q@tmp could not be found among [/home/jenkins/.jenkins, /home/jenkins/agent] $ docker run -t -d -u 10000:10000 -w /home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q -v /home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q:/home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q:rw,z -v /home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q@tmp:/home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q@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 ******** python:2.7 cat $ docker top 20801bdc7f7f4777b89a864c2cd52b03e3906d02ad3c708df4c4cdc5ebe4f45b -eo pid,comm [Pipeline] { [Pipeline] stage [Pipeline] { (dummy) [Pipeline] sh [aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q] Running shell script sh: 1: cannot create /home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q@tmp/durable-f19371c8/jenkins-log.txt: Directory nonexistent sh: 1: cannot create /home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q@tmp/durable-f19371c8/jenkins-result.txt: Directory nonexistent process apparently never started in /home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q@tmp/durable-f19371c8 ----------------------- work-leader is machine B, docker-44734997459c is, I believe, an instance of my custom jnlp-slave, as you can see the slave fails to run the python container I wonder if this could be some permissions issues, for now machine B is a VBox managed using vagrant, on it I can see that: vagrant@leader:~$ ls -l /home/jenkins/workspace/ total 8 drwxr-xr-x 2 root root 4096 Feb 26 02:02 aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q drwxr-xr-x 2 root root 4096 Feb 26 02:02 aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q@tmp vagrant@leader:~$ ls -la /home/jenkins/workspace/* /home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q: total 8 drwxr-xr-x 2 root root 4096 Feb 26 02:02 . drwxr-xr-x 4 root root 4096 Feb 26 02:02 .. /home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q@tmp: total 8 drwxr-xr-x 2 root root 4096 Feb 26 02:02 . drwxr-xr-x 4 root root 4096 Feb 26 02:02 .. Any idea? Chris Here is my Dockerfile (jenkins-slave-agent): ------------------------- FROM jenkinsci/jnlp-slave USER root curl -sfL -o docker.tgz https://.... && tar -C /usr/bin -xzf docker.tgz && rm docker.tgz USER jenkins ------------------------- And the project's Jenkinsfile: ------------------------------ pipeline { agent { docker 'python:2.7'} stages { stage('dummy') { steps { sh 'python --version' } } } } ------------------------------ Full build log: ------------------------------ Started by user admin Obtained Jenkinsfile from 0be91558399793412462578e0061fef50a7919c3 Running in Durability level: MAX_SURVIVABILITY [Pipeline] node Running on docker-44734997459c on work-leader in /home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q [Pipeline] { [Pipeline] stage [Pipeline] { (Declarative: Checkout SCM) [Pipeline] checkout Cloning the remote Git repository Cloning with configured refspecs honoured and without tags Cloning repository https://code.navico.cloud/scm/AA/aaa.git > git init > /home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q # timeout=10 Fetching upstream changes from https://code.navico.cloud/scm/AA/aaa.git > git --version # timeout=10 using GIT_ASKPASS to set credentials bb > git fetch --no-tags --progress https://code.navico.cloud/scm/AA/aaa.git +refs/heads/master:refs/remotes/origin/master > git config remote.origin.url https://code.navico.cloud/scm/AA/aaa.git # timeout=10 > git config --add remote.origin.fetch +refs/heads/master:refs/remotes/origin/master # timeout=10 > git config remote.origin.url https://code.navico.cloud/scm/AA/aaa.git # timeout=10 Fetching without tags Fetching upstream changes from https://code.navico.cloud/scm/AA/aaa.git using GIT_ASKPASS to set credentials bb > git fetch --no-tags --progress https://code.navico.cloud/scm/AA/aaa.git +refs/heads/master:refs/remotes/origin/master Checking out Revision 0be91558399793412462578e0061fef50a7919c3 (master) > git config core.sparsecheckout # timeout=10 > git checkout -f 0be91558399793412462578e0061fef50a7919c3 Commit message: "WIP" > git rev-list --no-walk 0be91558399793412462578e0061fef50a7919c3 # timeout=10 [Bitbucket] Notifying commit build result [Pipeline] } [Pipeline] // stage [Pipeline] withEnv [Pipeline] { [Pipeline] stage [Pipeline] { (Declarative: Agent Setup) [Pipeline] sh [aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q] Running shell script + docker pull python:2.7 2.7: Pulling from library/python Digest: sha256:d52278db7a8a4608e2b3c4b7a1a1eff76849542481144603bb9072512395a6d9 Status: Image is up to date for python:2.7 [Pipeline] } [Pipeline] // stage [Pipeline] sh [aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q] Running shell script + docker inspect -f . python:2.7 . [Pipeline] withDockerContainer docker-44734997459c on work-leader seems to be running inside container e7f7a4381e32c456b806695b9b7334751d88f1a3985867bb964e9fd3d2e8c948 but /home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q could not be found among [/home/jenkins/.jenkins, /home/jenkins/agent] but /home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q@tmp could not be found among [/home/jenkins/.jenkins, /home/jenkins/agent] $ docker run -t -d -u 10000:10000 -w /home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q -v /home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q:/home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q:rw,z -v /home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q@tmp:/home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q@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 ******** python:2.7 cat $ docker top 20801bdc7f7f4777b89a864c2cd52b03e3906d02ad3c708df4c4cdc5ebe4f45b -eo pid,comm [Pipeline] { [Pipeline] stage [Pipeline] { (dummy) [Pipeline] sh [aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q] Running shell script sh: 1: cannot create /home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q@tmp/durable-f19371c8/jenkins-log.txt: Directory nonexistent sh: 1: cannot create /home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q@tmp/durable-f19371c8/jenkins-result.txt: Directory nonexistent process apparently never started in /home/jenkins/workspace/aa_aaa_master-GQ43GQETZSZCK3GMCGYSLEW5TKL7YKHSBXYJPJLEX7A2AM6K5M6Q@tmp/durable-f19371c8 [Pipeline] } [Pipeline] // stage [Pipeline] } $ docker stop --time=1 20801bdc7f7f4777b89a864c2cd52b03e3906d02ad3c708df4c4cdc5ebe4f45b $ docker rm -f 20801bdc7f7f4777b89a864c2cd52b03e3906d02ad3c708df4c4cdc5ebe4f45b [Pipeline] // withDockerContainer [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline [Bitbucket] Notifying commit build result [Bitbucket] Build result notified ERROR: script returned exit code -2 Finished: FAILURE ---------------------- -- 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/CABxGUTgPOAD2PbvDrfmfqqUs1PP1FrkZhcg90zTtRU3%2B_ZUy9A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.