When running docker-compose up, you get an error. What is the likely cause?
medium
A. The ports mapping syntax is incorrect
B. The image name is invalid without a tag
C. The version number is not quoted, causing a YAML parsing error
D. Docker Compose does not support version 3.8
Solution
Step 1: Identify YAML syntax issue
The version field with a decimal must be quoted as a string to avoid YAML parsing errors.
Step 2: Check other fields for errors
Image name without tag is valid (defaults to latest), ports syntax is correct, and version 3.8 is supported.
Final Answer:
The version number is not quoted, causing a YAML parsing error -> Option C
Quick Check:
Unquoted decimal version causes YAML error [OK]
Hint: Always quote version numbers with decimals in Compose files [OK]
Common Mistakes:
Not quoting version with decimals
Assuming image needs explicit tag
Misreading ports syntax as error
5. You want to use a new Compose feature available only in version 3.9, but your current Compose file uses version "3.7". What is the best way to update your Compose file to use the new feature safely?
hard
A. Add the new feature without changing the version field, it will work automatically
B. Change the version field to "3.9" and test the file with your Docker Compose version
C. Downgrade your Docker Compose to an older version that supports 3.7 features only
D. Remove the version field entirely to let Docker Compose decide
Solution
Step 1: Update the version field to match the new feature
Set the version field to "3.9" to indicate use of new features introduced in that version.
Step 2: Test compatibility with your Docker Compose version
Ensure your Docker Compose installation supports version 3.9 to avoid errors.
Final Answer:
Change the version field to "3.9" and test the file with your Docker Compose version -> Option B
Quick Check:
Update version field and verify Compose support [OK]
Hint: Match version field to features and test Compose version support [OK]
Common Mistakes:
Using new features without updating version field
Removing version field causing unpredictable behavior
Ignoring Compose version compatibility
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.