0
0
Dockerdevops~10 mins

GitLab CI with Docker - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the Docker image used in the GitLab CI job.

Docker
image: [1]
Drag options to blanks, or click blank then click option'
Adocker:latest
Bubuntu:20.04
Cpython:3.12
Dnode:latest
Attempts:
3 left
💡 Hint
Common Mistakes
Using an image without Docker installed, so Docker commands fail.
Choosing an unrelated image like node or python when Docker is needed.
2fill in blank
medium

Complete the code to enable Docker commands in the GitLab CI job by specifying the service.

Docker
services:
  - [1]
Drag options to blanks, or click blank then click option'
Apostgres:latest
Bdocker:latest
Cubuntu:20.04
Ddocker:dind
Attempts:
3 left
💡 Hint
Common Mistakes
Using the main Docker image as a service instead of the Docker-in-Docker service.
Using unrelated services like Postgres.
3fill in blank
hard

Fix the error in the GitLab CI job to allow Docker commands by setting the correct variable.

Docker
variables:
  [1]: "/certs"
Drag options to blanks, or click blank then click option'
ADOCKER_DRIVER
BDOCKER_HOST
CDOCKER_TLS_CERTDIR
DDOCKER_TLS_VERIFY
Attempts:
3 left
💡 Hint
Common Mistakes
Setting unrelated Docker environment variables that do not enable TLS certs.
Omitting this variable causing Docker commands to fail.
4fill in blank
hard

Fill both blanks to define a job that builds a Docker image and pushes it to a registry.

Docker
build_image:
  stage: build
  script:
    - docker build -t [1] .
    - docker push [2]
Drag options to blanks, or click blank then click option'
Amyregistry/myimage:latest
Bmyregistry/myimage:stable
Dmyregistry/myimage:dev
Attempts:
3 left
💡 Hint
Common Mistakes
Using different tags for build and push causing push to fail.
Using invalid image tags.
5fill in blank
hard

Fill all three blanks to define a GitLab CI job that logs in to Docker registry, builds, and pushes an image.

Docker
deploy:
  stage: deploy
  script:
    - echo $[1] | docker login -u $[2] --password-stdin $CI_REGISTRY
    - docker build -t [3] .
    - docker push [3]
Drag options to blanks, or click blank then click option'
A$CI_REGISTRY_PASSWORD
B$CI_REGISTRY_USER
Cmyregistry/myapp:prod
D$CI_REGISTRY_TOKEN
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up username and password variables.
Using different tags for build and push.
Forgetting to pipe the password to docker login.