0
0
Jenkinsdevops~10 mins

Docker-in-Docker considerations in Jenkins - Interactive Code Practice

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

Complete the code to run Docker inside a Jenkins pipeline using Docker-in-Docker.

Jenkins
pipeline {
  agent {
    docker {
      image '[1]'
      args '--privileged'
    }
  }
  stages {
    stage('Build') {
      steps {
        sh 'docker info'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aalpine:3.12
Bubuntu:latest
Cdocker:dind
Dnode:14
Attempts:
3 left
💡 Hint
Common Mistakes
Using a base image without Docker installed like ubuntu or alpine.
Forgetting to add the --privileged flag.
2fill in blank
medium

Complete the Jenkins pipeline step to start the Docker daemon inside the container.

Jenkins
steps {
  sh '[1] -b tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock &'
}
Drag options to blanks, or click blank then click option'
Adockerd
Bdocker
Cdocker-compose
Dservice docker start
Attempts:
3 left
💡 Hint
Common Mistakes
Using docker instead of dockerd.
Trying to start Docker with service commands inside the container.
3fill in blank
hard

Fix the error in the Docker-in-Docker Jenkins pipeline by completing the missing argument to allow privileged mode.

Jenkins
agent {
  docker {
    image 'docker:dind'
    args '[1]'
  }
}
Drag options to blanks, or click blank then click option'
A-v /var/run/docker.sock:/var/run/docker.sock
B--network host
C--rm
D--privileged
Attempts:
3 left
💡 Hint
Common Mistakes
Using volume mount flags instead of privileged mode.
Forgetting to add any arguments.
4fill in blank
hard

Fill both blanks to correctly mount the Docker socket and set environment variable for Docker-in-Docker.

Jenkins
agent {
  docker {
    image 'docker:dind'
    args '[1] [2]'
  }
}
Drag options to blanks, or click blank then click option'
A-v /var/run/docker.sock:/var/run/docker.sock
B-e DOCKER_HOST=unix:///var/run/docker.sock
C--privileged
D-p 2375:2375
Attempts:
3 left
💡 Hint
Common Mistakes
Using privileged flag instead of mounting the socket.
Not setting the DOCKER_HOST environment variable.
5fill in blank
hard

Fill all three blanks to create a Jenkins pipeline step that builds a Docker image, tags it, and pushes it to a registry.

Jenkins
steps {
  sh 'docker build -t [1] .'
  sh 'docker tag [2] myregistry.com/myimage:latest'
  sh 'docker push [3]'
}
Drag options to blanks, or click blank then click option'
Amyimage:latest
Cmyregistry.com/myimage:latest
Dmyimage
Attempts:
3 left
💡 Hint
Common Mistakes
Using the full registry path in the build command.
Tagging with the wrong image name.
Pushing the wrong image tag.