Complete the code to run Docker inside a Jenkins pipeline using Docker-in-Docker.
pipeline {
agent {
docker {
image '[1]'
args '--privileged'
}
}
stages {
stage('Build') {
steps {
sh 'docker info'
}
}
}
}The docker:dind image includes the Docker daemon needed for Docker-in-Docker.
Complete the Jenkins pipeline step to start the Docker daemon inside the container.
steps {
sh '[1] -b tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock &'
}docker instead of dockerd.dockerd is the Docker daemon command that starts the Docker service inside the container.
Fix the error in the Docker-in-Docker Jenkins pipeline by completing the missing argument to allow privileged mode.
agent {
docker {
image 'docker:dind'
args '[1]'
}
}The --privileged flag is required to allow Docker-in-Docker to run properly with full permissions.
Fill both blanks to correctly mount the Docker socket and set environment variable for Docker-in-Docker.
agent {
docker {
image 'docker:dind'
args '[1] [2]'
}
}Mounting the Docker socket allows the container to communicate with the host Docker daemon. Setting DOCKER_HOST points Docker commands to the correct daemon.
Fill all three blanks to create a Jenkins pipeline step that builds a Docker image, tags it, and pushes it to a registry.
steps {
sh 'docker build -t [1] .'
sh 'docker tag [2] myregistry.com/myimage:latest'
sh 'docker push [3]'
}The build tags the image as myimage. Then it is tagged with the full registry path before pushing.