Complete the code to specify the Docker build step in a Jenkins pipeline.
stage('Build Docker Image') { steps { script { dockerImage = docker.[1]('myapp:latest') } } }
The docker.build command builds a Docker image from the Dockerfile in the workspace.
Complete the code to push the built Docker image to a registry in the Jenkins pipeline.
stage('Push Docker Image') { steps { script { dockerImage.[1]() } } }
The push method uploads the Docker image to the specified registry.
Fix the error in the Jenkins pipeline code to correctly build a Docker image with a custom Dockerfile path.
stage('Build Custom Docker Image') { steps { script { dockerImage = docker.[1]('myapp:custom', '-f Dockerfile.custom .') } } }
The build method accepts the image name and build arguments like the Dockerfile path.
Fill both blanks to build and push a Docker image with a tag in a Jenkins pipeline.
stage('Build and Push') { steps { script { dockerImage = docker.[1]('myapp:[2]') dockerImage.push() } } }
Use build to create the image and dev as the tag for development version.
Fill all three blanks to build a Docker image, tag it, and push it to a registry in a Jenkins pipeline.
stage('Build, Tag, and Push') { steps { script { dockerImage = docker.[1]('myapp:[2]') dockerImage.[3]('myregistry.com/myapp:[2]') } } }
First, build creates the image. Then tag adds a registry tag. Finally, push uploads it.