0
0
Dockerdevops~20 mins

Compose file versioning in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Compose File Versioning Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding Compose file version declaration
What is the purpose of specifying the version field at the top of a Docker Compose file?
AIt defines the Docker Compose file format version, which determines available features and syntax.
BIt sets the Docker Engine API version to use when running containers.
CIt specifies the version of the base image used in all services.
DIt controls the version of the Docker CLI installed on the host machine.
Attempts:
2 left
💡 Hint
Think about how Compose files evolve and how Docker knows which syntax rules to apply.
💻 Command Output
intermediate
2:00remaining
Output of docker-compose with unsupported version
Given this Compose file snippet, what will be the output or result when running docker-compose up?
version: '5.0'
services:
  web:
    image: nginx
Docker
version: '5.0'
services:
  web:
    image: nginx
AStarts the nginx container successfully with no warnings.
BSyntaxError: Invalid YAML format in Compose file.
CError: Unsupported Compose file version "5.0". Supported versions are "3", "3.8", etc.
DWarning: Version 5.0 is deprecated, but containers start anyway.
Attempts:
2 left
💡 Hint
Check which Compose file versions are officially supported by Docker Compose.
Configuration
advanced
1:30remaining
Compose file version and feature compatibility
Which Compose file version must be used to enable the profiles feature that allows conditional service startup?
Aversion: '2.4'
Bversion: '3.3'
Cversion: '3.7'
Dversion: '3.9'
Attempts:
2 left
💡 Hint
Profiles were introduced in a recent Compose file version starting with 3.x.
Troubleshoot
advanced
2:00remaining
Diagnosing version mismatch issues
You have a Compose file with version: '3.8' but when running docker-compose up, some features like secrets are not working as expected. What is the most likely cause?
AThe Docker Engine version is too old and does not support Compose file 3.8 features.
BThe Compose file syntax is incorrect and causes parsing errors.
CThe <code>version</code> field must be removed to enable all features.
DDocker Compose does not support secrets in any version.
Attempts:
2 left
💡 Hint
Check compatibility between Docker Engine and Compose file features.
Best Practice
expert
2:30remaining
Choosing Compose file version for multi-environment projects
For a project that needs to run on both local developer machines and a cloud CI/CD pipeline with different Docker versions, which Compose file version strategy is best to ensure maximum compatibility?
AUse the latest Compose file version and require all environments to upgrade Docker.
BUse the lowest Compose file version supported by all environments, even if it limits features.
COmit the <code>version</code> field entirely to let Docker Compose auto-detect features.
DMaintain multiple Compose files with different versions and merge them at runtime.
Attempts:
2 left
💡 Hint
Think about stability and compatibility across different environments.