Bird
0
0

Given this GitLab CI job snippet, what will be the output of the docker ps command inside the job?

medium📝 Command Output Q13 of 15
Docker - in CI/CD
Given this GitLab CI job snippet, what will be the output of the docker ps command inside the job?
job:
  image: docker:latest
  services:
    - docker:dind
  script:
    - docker info
    - docker ps
AShows an error: Docker daemon not running
BLists running containers inside the dind service (likely empty)
CLists containers on the host machine
DOutputs the Docker version only
Step-by-Step Solution
Solution:
  1. Step 1: Understand the environment of the job

    The job uses docker:dind service, which runs a Docker daemon inside the CI environment. The docker ps command connects to this daemon.
  2. Step 2: Predict the output of docker ps

    Since the job just started and no containers were run inside the dind daemon, docker ps will list running containers inside the dind environment, which is likely empty.
  3. Final Answer:

    Lists running containers inside the dind service (likely empty) -> Option B
  4. Quick Check:

    docker ps inside dind = running containers (empty if none) [OK]
Quick Trick: docker ps shows containers inside dind, not host [OK]
Common Mistakes:
  • Expecting error about Docker daemon
  • Thinking it lists host machine containers
  • Confusing docker info output with docker ps

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes