Bird
0
0

Which of the following is the correct syntax to define a GitLab CI job that uses Docker and runs a simple command?

easy📝 Syntax Q3 of 15
Docker - in CI/CD
Which of the following is the correct syntax to define a GitLab CI job that uses Docker and runs a simple command?
Abuild_job:\n image: docker latest\n script:\n - echo 'Building...'
Bbuild_job:\n image: docker:latest\n script:\n - echo 'Building...'
Cbuild_job:\n image docker:latest\n script:\n - echo 'Building...'
Dbuild_job:\n image: 'docker latest'\n script:\n - echo 'Building...'
Step-by-Step Solution
Solution:
  1. Step 1: Check YAML syntax for job definition

    The correct YAML syntax uses a colon after keys and proper indentation. build_job:\n image: docker:latest\n script:\n - echo 'Building...' uses colons and indentation correctly.
  2. Step 2: Validate image name format

    build_job:\n image: docker:latest\n script:\n - echo 'Building...' uses docker:latest which is the correct image tag format. Others have missing colons or wrong spacing.
  3. Final Answer:

    Correct YAML with image and script keys properly formatted -> Option B
  4. Quick Check:

    YAML syntax + image tag = build_job:\n image: docker:latest\n script:\n - echo 'Building...' [OK]
Quick Trick: Use colons and proper indentation in YAML [OK]
Common Mistakes:
  • Missing colon after keys
  • Wrong image tag format
  • Incorrect indentation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes