0
0
Jenkinsdevops~20 mins

Pushing images to registry in Jenkins - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Docker Push Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this Jenkins pipeline step?

Consider this Jenkins pipeline snippet that pushes a Docker image to a registry:

stage('Push Image') {
  steps {
    script {
      docker.withRegistry('https://myregistry.example.com', 'registry-credentials') {
        def appImage = docker.build('myapp:latest')
        appImage.push()
      }
    }
  }
}

What will Jenkins output if the push is successful?

ASuccessfully pushed image myapp:latest to https://myregistry.example.com
BError: No such image: myapp:latest
CPermission denied: failed to push image to registry
DSyntax error in Jenkinsfile at line 3
Attempts:
2 left
💡 Hint

Think about what Jenkins logs when a Docker image push succeeds inside docker.withRegistry.

Configuration
intermediate
1:30remaining
Which Jenkins credential type is required for pushing Docker images?

You want to push Docker images to a private registry from Jenkins. Which credential type should you configure in Jenkins to authenticate properly?

ASSH Username with private key
BUsername with password
CSecret text
DCertificate
Attempts:
2 left
💡 Hint

Docker registries usually require a username and password for login.

Troubleshoot
advanced
2:00remaining
Why does this Jenkins pipeline fail to push the image?

Given this Jenkins pipeline snippet:

stage('Push Image') {
  steps {
    script {
      def appImage = docker.build('myapp:latest')
      appImage.push()
    }
  }
}

The push step fails with an authentication error. What is the most likely cause?

AMissing <code>docker.withRegistry</code> block to provide registry credentials
BThe image name 'myapp:latest' is invalid
CThe Jenkinsfile syntax is incorrect
DDocker daemon is not running on the Jenkins agent
Attempts:
2 left
💡 Hint

Think about how Jenkins provides credentials to Docker commands.

🔀 Workflow
advanced
2:30remaining
What is the correct order of steps to push a Docker image in Jenkins?

Arrange these steps in the correct order to build and push a Docker image to a registry in Jenkins:

A3,4,1,2
B4,1,3,2
C4,3,1,2
D1,4,3,2
Attempts:
2 left
💡 Hint

Think about when authentication must happen relative to building and pushing.

Best Practice
expert
2:00remaining
Which practice improves security when pushing Docker images in Jenkins?

Which of the following practices best improves security when pushing Docker images to a registry in Jenkins pipelines?

AStore registry credentials as plain text environment variables in Jenkinsfile
BPush images without authentication to speed up the pipeline
CHardcode registry username and password in the Dockerfile
DUse Jenkins credentials plugin to store and inject registry credentials securely
Attempts:
2 left
💡 Hint

Consider how Jenkins manages sensitive information securely.