0
0
Dockerdevops~10 mins

Health checks in Compose in Docker - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a health check command in Docker Compose.

Docker
healthcheck:
  test: ["CMD", [1]]
Drag options to blanks, or click blank then click option'
A"echo healthy"
B"curl -f http://localhost"
C"ping -c 1 localhost"
D"curl -f http://localhost/ || exit 1"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a command that always succeeds like 'echo healthy'.
Omitting the 'exit 1' on failure.
2fill in blank
medium

Complete the code to set the health check interval to 30 seconds.

Docker
healthcheck:
  interval: [1]
Drag options to blanks, or click blank then click option'
A10s
B30s
C1m
D5s
Attempts:
3 left
💡 Hint
Common Mistakes
Using '1m' which is 1 minute, not 30 seconds.
Using a number without 's' suffix.
3fill in blank
hard

Fix the error in the health check restart policy syntax.

Docker
restart: [1]
Drag options to blanks, or click blank then click option'
Aunless-stopped
Bon-failure
Crestart-always
Dalways
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid value like 'restart-always'.
Confusing 'on-failure' with 'always'.
4fill in blank
hard

Fill both blanks to set retries to 5 and timeout to 10 seconds in health check.

Docker
healthcheck:
  retries: [1]
  timeout: [2]
Drag options to blanks, or click blank then click option'
A5
B3
C10s
D30s
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping retries and timeout values.
Using timeout without 's' suffix.
5fill in blank
hard

Fill all three blanks to create a health check with command 'curl -f http://localhost/', interval 20 seconds, and start period 5 seconds.

Docker
healthcheck:
  test: ["CMD", [1]]
  interval: [2]
  start_period: [3]
Drag options to blanks, or click blank then click option'
A"curl -f http://localhost/ || exit 1"
B20s
C5s
D"curl http://localhost"
Attempts:
3 left
💡 Hint
Common Mistakes
Using incomplete curl command.
Omitting start_period or using wrong format.