0
0
Dockerdevops~20 mins

Why advanced Compose features matter in Docker - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Compose Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why use Docker Compose override files?

Docker Compose allows using multiple files like docker-compose.yml and docker-compose.override.yml. What is the main benefit of using override files?

AThey let you change or add service settings without modifying the original compose file.
BThey automatically update Docker images to the latest version.
CThey enable running Compose commands without Docker installed.
DThey convert Compose files into Kubernetes manifests.
Attempts:
2 left
💡 Hint

Think about how you can keep your base setup safe while customizing for different environments.

💻 Command Output
intermediate
2:00remaining
Output of 'docker-compose config' with multiple files

Given these two Compose files:

docker-compose.yml:
version: '3'
services:
  web:
    image: nginx
    ports:
      - "80:80"

docker-compose.override.yml:
version: '3'
services:
  web:
    environment:
      - DEBUG=true

What is the output of docker-compose -f docker-compose.yml -f docker-compose.override.yml config?

AA warning about conflicting versions and no output.
BAn error because multiple files cannot be used with the config command.
COnly the base file content without environment variables.
DA combined configuration showing the web service with image nginx, port 80:80, and environment DEBUG=true.
Attempts:
2 left
💡 Hint

Think about how Compose merges multiple files.

🔀 Workflow
advanced
2:00remaining
Using profiles to control service startup

You want to start only a subset of services defined in your Compose file based on the environment. Which Compose feature helps you do this?

AProfiles allow grouping services and starting only those groups with <code>--profile</code> option.
BUsing multiple Compose files with <code>-f</code> to exclude services.
CManually commenting out services in the Compose file before running.
DSetting environment variables inside the Compose file to disable services.
Attempts:
2 left
💡 Hint

Think about a way to tag services and choose which tags to run.

Troubleshoot
advanced
2:00remaining
Why does 'depends_on' not wait for service readiness?

You use depends_on in your Compose file to start services in order. However, sometimes your app fails because the dependency is not ready. Why?

AThe dependency service must be manually started before the dependent service.
B<code>depends_on</code> only waits for container start, not for the service inside to be ready.
CDocker Compose does not support <code>depends_on</code> in version 3 files.
D<code>depends_on</code> requires a special flag to wait for readiness that is missing.
Attempts:
2 left
💡 Hint

Think about the difference between a container running and the app inside being ready.

Best Practice
expert
2:00remaining
Why use extension fields (&) in Compose files?

In Docker Compose, what is the main advantage of using YAML anchors and extension fields (using & and *)?

AThey automatically convert Compose files to Kubernetes YAML.
BThey enable running Compose files faster by caching repeated sections.
CThey let you reuse and share configuration snippets to avoid repetition and errors.
DThey allow environment variables to be encrypted inside the Compose file.
Attempts:
2 left
💡 Hint

Think about how you avoid copying the same text multiple times.