Complete the code to specify the Docker image used in the GitLab CI job.
image: [1]The image keyword in GitLab CI specifies the Docker image to use for the job. Using docker:latest allows Docker commands inside the job.
Complete the code to enable Docker commands in the GitLab CI job by specifying the service.
services:
- [1]The docker:dind service runs Docker-in-Docker, allowing Docker commands to run inside the CI job.
Fix the error in the GitLab CI job to allow Docker commands by setting the correct variable.
variables: [1]: "/certs"
Setting DOCKER_TLS_CERTDIR to "/certs" enables TLS certificates for secure Docker daemon communication in GitLab CI.
Fill both blanks to define a job that builds a Docker image and pushes it to a registry.
build_image:
stage: build
script:
- docker build -t [1] .
- docker push [2]Both build and push commands must use the same image tag to ensure the correct image is pushed.
Fill all three blanks to define a GitLab CI job that logs in to Docker registry, builds, and pushes an image.
deploy:
stage: deploy
script:
- echo $[1] | docker login -u $[2] --password-stdin $CI_REGISTRY
- docker build -t [3] .
- docker push [3]The job uses $CI_REGISTRY_PASSWORD to login, $CI_REGISTRY_USER as username, and tags the image consistently for build and push.