-1
in short, I’m trying to run one container inside another. Where the first container to go up is based on a Jenkins image and the second on a gcc image (which is only for testing).
this is the step by step of what I did:
I raised a Jenkins container based on the image
jenkins\jenkins
with the following command:docker run -it -p 1234:8080 -v jenkins_home:/var/jenkins_home -u 0 jenkins/jenkins
jenkins_home
is a volume created with the commanddocker volume create jenkins_home
I installed the plugins Docker, Docker Slaves and Docker Pipeline.
I created a job pipeline:
pipeline { stages { stage('Container') { agent { docker { image 'gcc' args '-v ${nomedocurso}:/curso/' } } steps { sh 'ls -l' } } } }
- In that step, Jnenkins was not finding Docker:
+ Docker Inspect -f . gcc /var/jenkins_home/Workspace/curso-c@2@tmp/Durable-ee333f1e/script.sh: 1: /var/jenkins_home/Workspace/curso-c@2@tmp/Durable-ee333f1e/script.sh: Docker: not found
- In that step, Jnenkins was not finding Docker:
I tried to include the label parameter:
pipeline { agent { label 'docker' } stages { stage('Container') { agent { docker { label 'docker' image 'gcc' args '-v ${nomedocurso}:/curso/' } } steps { sh 'ls -l' } } } }
- But Jenkins kept complaining:
Still Waiting to Schedule task
pra Jenkins' doesn’t have label ːDocker'
- But Jenkins kept complaining:
- Because Docker’s not being found by Jenkins?
- How to set up and run a Docker pipeline in one of the stages?
This Jenkins image does not have the Docker engine installed. If you want to handle containers using an image with Jenkins and Docker the best solution is to provision one with everything you need.
– Antonio Azambuja
@Antonioazambuja you know some to recommend?
– Gabriel Hardoim
Can you verify the answer? Don’t forget to accept it if you are satisfied with it.
– tvdias