0
0
Dockerdevops~20 mins

GitLab CI with Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
GitLab CI Docker Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
GitLab CI Runner Docker Image Output
What is the output of the following command when run inside a GitLab CI job using the official Docker image docker:latest?
Docker
docker --version
ADocker version 20.10.23, build 7155243
BError: Cannot connect to the Docker daemon
CDocker version 18.09.1, build 4c52b90
Dbash: docker: command not found
Attempts:
2 left
💡 Hint
The official Docker image used in GitLab CI jobs includes the Docker CLI by default.
Configuration
intermediate
2:00remaining
Correct Docker-in-Docker Service Configuration
Which GitLab CI configuration snippet correctly enables Docker-in-Docker (DinD) service for building Docker images inside a job?
A
services:
  - docker:dind
variables:
  DOCKER_HOST: tcp://docker:2375
  DOCKER_TLS_CERTDIR: ""
B
services:
  - docker:latest
variables:
  DOCKER_HOST: unix:///var/run/docker.sock
C
services:
  - docker:dind
variables:
  DOCKER_HOST: unix:///var/run/docker.sock
D
services:
  - docker:dind
variables:
  DOCKER_HOST: tcp://localhost:2375
  DOCKER_TLS_CERTDIR: ""
Attempts:
2 left
💡 Hint
DinD requires connecting to the Docker daemon over TCP and disabling TLS cert directory.
🔀 Workflow
advanced
3:00remaining
Order of Steps to Build and Push Docker Image in GitLab CI
Arrange the following steps in the correct order to build and push a Docker image using GitLab CI with Docker-in-Docker service.
A1,2,4,3
B1,4,2,3
C4,2,1,3
D4,1,2,3
Attempts:
2 left
💡 Hint
You must prepare the environment before logging in and building images.
Troubleshoot
advanced
2:00remaining
Diagnosing Docker Push Failure in GitLab CI
A GitLab CI job using Docker-in-Docker fails with the error: denied: requested access to the resource is denied when pushing an image. What is the most likely cause?
ADocker image build failed before push
BDocker-in-Docker service is not started
CDocker registry login credentials are missing or incorrect
DGitLab runner does not have network access
Attempts:
2 left
💡 Hint
Access denied errors usually relate to authentication.
Best Practice
expert
3:00remaining
Best Practice for Secure Docker-in-Docker Usage in GitLab CI
Which practice is recommended to securely use Docker-in-Docker in GitLab CI pipelines?
ADisable TLS and use plain TCP connection for simplicity
BRun DinD service with TLS enabled and use certificates for authentication
CUse Docker socket binding from host to avoid DinD service
DRun Docker commands directly on the GitLab runner host
Attempts:
2 left
💡 Hint
Security is important when exposing Docker daemon.