Complete the code to build a Docker image named 'myapp' using the Dockerfile in the current directory.
docker build -t myapp[1] .-p in build command.-f when default is used.--rm which is for container run, not build.The -t option tags the image. Adding :latest specifies the tag explicitly.
Complete the Jenkins pipeline step to push the Docker image 'myapp:latest' to Docker Hub.
sh 'docker push myapp[1]'
The image tag :latest is the default and commonly used for pushing the most recent image.
Fix the error in the Jenkins pipeline step that logs in to Docker Hub using environment variables.
sh 'docker login -u [1] -p $DOCKER_PASSWORD'
$ before environment variables.Environment variables in shell commands need the $ prefix to be expanded.
Fill both blanks to tag the Docker image 'myapp' with the build number and push it.
sh 'docker tag myapp myapp:[1]' sh 'docker push myapp:[2]'
${} in shell commands.Use ${BUILD_NUMBER} to insert the Jenkins build number variable in shell commands.
Fill all three blanks to create a Docker image, tag it with the build number, and push it in a Jenkins pipeline.
sh 'docker build -t myapp:[1] .' sh 'docker tag myapp:[2] myrepo/myapp:[3]' sh 'docker push myrepo/myapp:[3]'
${} around environment variables.Use ${BUILD_NUMBER} consistently to tag and push the image with the Jenkins build number.