Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to log in to a Docker registry using Jenkins pipeline.
Jenkins
sh 'docker [1] myregistry.example.com -u user -p password'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'docker push' instead of 'docker login' for authentication.
Using 'docker build' which is for building images, not logging in.
✗ Incorrect
The 'docker login' command authenticates to the Docker registry before pushing images.
2fill in blank
mediumComplete the code to tag a Docker image before pushing it to the registry.
Jenkins
sh 'docker tag myapp:latest [1]/myapp:latest'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'latest' alone without registry URL.
Using 'docker.io' when the target registry is different.
✗ Incorrect
Tagging the image with the registry URL prepares it for pushing to that registry.
3fill in blank
hardFix the error in the Jenkins pipeline step to push the Docker image to the registry.
Jenkins
sh 'docker [1] myregistry.example.com/myapp:latest'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'docker build' which only builds images locally.
Using 'docker login' which is for authentication, not pushing.
✗ Incorrect
The 'docker push' command uploads the tagged image to the registry.
4fill in blank
hardFill both blanks to build and push a Docker image in Jenkins pipeline.
Jenkins
sh 'docker [1] -t myregistry.example.com/myapp:latest . && docker [2] myregistry.example.com/myapp:latest'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of build and push commands.
Using 'docker run' instead of 'docker push' to upload.
✗ Incorrect
First build the image with 'docker build', then push it with 'docker push'.
5fill in blank
hardFill all three blanks to log in, build, and push a Docker image in Jenkins pipeline.
Jenkins
sh 'docker [1] myregistry.example.com -u user -p password && docker [2] -t myregistry.example.com/myapp:latest . && docker [3] myregistry.example.com/myapp:latest'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Skipping login before pushing.
Using 'docker run' instead of 'docker push'.
✗ Incorrect
First log in to authenticate, then build the image, and finally push it to the registry.