Challenge - 5 Problems
Docker Pipeline Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of Docker Pipeline build step
What is the output of the following Jenkins Pipeline snippet using the Docker Pipeline plugin?
Jenkins
pipeline {
agent any
stages {
stage('Build') {
steps {
script {
def img = docker.build('my-image:latest')
echo img.id
}
}
}
}
}Attempts:
2 left
💡 Hint
The docker.build() method returns an image object with an id property.
✗ Incorrect
The docker.build('my-image:latest') command builds the Docker image and returns an image object. The img.id property contains the image's unique ID string.
🧠 Conceptual
intermediate1:30remaining
Understanding Docker Pipeline plugin's 'inside' method
In Jenkins Docker Pipeline plugin, what does the 'inside' method do when called on a Docker image object?
Attempts:
2 left
💡 Hint
Think about running commands inside a container environment.
✗ Incorrect
The 'inside' method runs the enclosed pipeline steps inside a container started from the specified Docker image, providing an isolated environment.
🔀 Workflow
advanced2:30remaining
Correct order of Docker Pipeline plugin steps to build, test, and push
Arrange the following Docker Pipeline plugin steps in the correct order to build an image, run tests inside it, and then push it to a registry.
Attempts:
2 left
💡 Hint
You must define the image variable before using it.
✗ Incorrect
First, define the image variable by assigning the result of docker.build. Then build the image, run tests inside it, and finally push it.
❓ Troubleshoot
advanced2:00remaining
Diagnosing Docker Pipeline plugin authentication failure
You get an error 'unauthorized: authentication required' when running 'image.push()' in Jenkins Docker Pipeline plugin. What is the most likely cause?
Attempts:
2 left
💡 Hint
Pushing requires authentication to the registry.
✗ Incorrect
The 'unauthorized' error means the pipeline lacks proper credentials to push to the Docker registry.
✅ Best Practice
expert3:00remaining
Best practice for cleaning up Docker images in Jenkins pipeline
Which approach is best to avoid disk space issues caused by leftover Docker images when using the Docker Pipeline plugin in Jenkins?
Attempts:
2 left
💡 Hint
Cleaning up images programmatically after use is efficient.
✗ Incorrect
Calling 'remove()' on the image object after pushing deletes the local image and frees disk space automatically.