0
0
Jenkinsdevops~10 mins

Docker agent in Jenkinsfile - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify a Docker agent in the Jenkinsfile.

Jenkins
pipeline {
  agent {
    docker {
      image '[1]'
    }
  }
  stages {
    stage('Build') {
      steps {
        echo 'Building inside Docker container'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aalpine:3.12
Bnode:14
Cpython:3.8
Dubuntu:latest
Attempts:
3 left
💡 Hint
Common Mistakes
Using an invalid image name.
Forgetting to put the image name in quotes.
2fill in blank
medium

Complete the code to add a custom Docker argument in the Jenkinsfile.

Jenkins
pipeline {
  agent {
    docker {
      image 'python:3.8'
      args '[1]'
    }
  }
  stages {
    stage('Test') {
      steps {
        echo 'Running tests inside Docker'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
A--rm
B--privileged
C-d
D-v /tmp:/tmp
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid Docker arguments.
Not quoting the args string.
3fill in blank
hard

Fix the error in the Jenkinsfile Docker agent declaration.

Jenkins
pipeline {
  agent {
    docker {
      image '[1]'
    }
  }
  stages {
    stage('Deploy') {
      steps {
        echo 'Deploying inside Docker container'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Anode:14
Bnode-14
Cnode14
Dnode/14
Attempts:
3 left
💡 Hint
Common Mistakes
Using colon after image key.
Using invalid image names.
4fill in blank
hard

Fill both blanks to specify a Docker agent with a custom image and reuse the workspace.

Jenkins
pipeline {
  agent {
    docker {
      image '[1]'
      reuseNode [2]
    }
  }
  stages {
    stage('Build') {
      steps {
        echo 'Building with Docker agent'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Amaven:3.6.3-jdk-11
Btrue
Cfalse
Dnode:16
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid image names.
Setting reuseNode to a string instead of boolean.
5fill in blank
hard

Fill all three blanks to define a Docker agent with image, args, and label.

Jenkins
pipeline {
  agent {
    docker {
      image '[1]'
      args '[2]'
      label '[3]'
    }
  }
  stages {
    stage('Test') {
      steps {
        echo 'Testing inside Docker container'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Apython:3.9-slim
B-v /var/run/docker.sock:/var/run/docker.sock
Cdocker-agent
Dnode:12-alpine
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid Docker arguments.
Forgetting to quote the label string.