0
0
Jenkinsdevops~10 mins

Docker image as artifact 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 build a Docker image named 'myapp' using the Dockerfile in the current directory.

Jenkins
docker build -t myapp[1] .
Drag options to blanks, or click blank then click option'
A:latest
B-f Dockerfile
C--rm
D-p 8080:80
Attempts:
3 left
💡 Hint
Common Mistakes
Using port mapping option -p in build command.
Specifying Dockerfile with -f when default is used.
Using --rm which is for container run, not build.
2fill in blank
medium

Complete the Jenkins pipeline step to push the Docker image 'myapp:latest' to Docker Hub.

Jenkins
sh 'docker push myapp[1]'
Drag options to blanks, or click blank then click option'
A:stable
B:1.0
C:dev
D:latest
Attempts:
3 left
💡 Hint
Common Mistakes
Pushing an image tag that was not built.
Omitting the tag and causing push failure.
Using a tag that does not exist locally.
3fill in blank
hard

Fix the error in the Jenkins pipeline step that logs in to Docker Hub using environment variables.

Jenkins
sh 'docker login -u [1] -p $DOCKER_PASSWORD'
Drag options to blanks, or click blank then click option'
A$USERNAME
BDOCKER_USERNAME
C$DOCKER_USERNAME
Ddocker_user
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the $ before environment variables.
Using incorrect variable names.
Passing plain strings instead of variables.
4fill in blank
hard

Fill both blanks to tag the Docker image 'myapp' with the build number and push it.

Jenkins
sh 'docker tag myapp myapp:[1]'
sh 'docker push myapp:[2]'
Drag options to blanks, or click blank then click option'
ABUILD_NUMBER
Blatest
C${BUILD_NUMBER}
D1.0
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names without ${} in shell commands.
Using different tags for tag and push commands.
Using static tags instead of build number.
5fill in blank
hard

Fill all three blanks to create a Docker image, tag it with the build number, and push it in a Jenkins pipeline.

Jenkins
sh 'docker build -t myapp:[1] .'
sh 'docker tag myapp:[2] myrepo/myapp:[3]'
sh 'docker push myrepo/myapp:[3]'
Drag options to blanks, or click blank then click option'
Alatest
B${BUILD_NUMBER}
D1.0
Attempts:
3 left
💡 Hint
Common Mistakes
Using different tags in build and push commands.
Omitting ${} around environment variables.
Using static tags instead of dynamic build number.