Courseiva

XK0-006 Automation, Orchestration, and Scripting Practice Question

An administrator needs to deploy a set of microservices using Docker Compose. The services require configuration values that vary between development and production environments. Which approach allows the administrator to override values without modifying the docker-compose.yml file?

⚠ Common exam trap

The trap is selecting extends or profiles for environment-specific overrides; candidates must remember that multi-file merging with -f is the canonical Docker Compose pattern for layering environment configurations.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Use multiple compose files with the -f flag: docker-compose -f docker-compose.yml -f docker-compose.prod.yml up.

Docker Compose supports merging multiple compose files via the -f flag, where later files override or extend values from earlier ones. Running docker-compose -f docker-compose.yml -f docker-compose.prod.yml up applies the base configuration and then overlays production-specific values without editing the original file.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Define multiple services in one docker-compose.yml and use profiles.

    Why it's wrong here

    Profiles toggle which services start, not the configuration values those services receive, so development and production would still share identical variables. It is tempting because profiles cleanly separate service sets per environment, which is correct when the environments differ in which containers run rather than in their settings.

  • ✗

    Use environment variables in the Dockerfile and pass them via docker run -e.

    Why it's wrong here

    Dockerfile ENV values are baked into the image at build time, and docker run bypasses Compose entirely, so neither overrides values for a Compose deployment. It is tempting because environment variables are the standard mechanism for injecting configuration, which works when running containers individually rather than through Compose.

  • ✗

    Use the extends keyword in docker-compose.yml.

    Why it's wrong here

    The extends keyword merges a base service definition into another file at parse time; it composes service definitions, not environment-specific values, so it cannot override configuration per environment. It is tempting because extends does let you avoid duplicating YAML, which suits sharing common service structure across projects.

  • ✓

    Use multiple compose files with the -f flag: docker-compose -f docker-compose.yml -f docker-compose.prod.yml up.

    Why this is correct

    Layering multiple Compose files with the `-f` flag merges them at runtime, with later files overriding earlier values. This satisfies the requirement to vary configuration between development and production without editing `docker-compose.yml`, since the base file stays untouched and environment-specific overrides live in a separate file.

About these practice questions

Courseiva writes every XK0-006 question from scratch — 781 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official CompTIA exam blueprint

This XK0-006 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the XK0-006 exam.