0
0
Dockerdevops~10 mins

Container health checks in Docker - Interactive Code Practice

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

Complete the Dockerfile line to add a health check that runs the command 'curl -f http://localhost/'

Docker
HEALTHCHECK CMD [1]
Drag options to blanks, or click blank then click option'
Acurl -f http://localhost/
Becho 'healthy'
Cls /app
Dping -c 1 localhost
Attempts:
3 left
💡 Hint
Common Mistakes
Using commands that do not test the service health like 'ls' or 'echo'.
Using ping which may not be installed or meaningful inside the container.
2fill in blank
medium

Complete the Docker Compose service definition to add a health check that retries every 10 seconds

Docker
healthcheck:
  test: [1]
  interval: 10s
Drag options to blanks, or click blank then click option'
A["CMD", "curl", "-f", "http://localhost/"]
Bcurl -f http://localhost/
C"curl -f http://localhost/"
D["RUN", "curl", "-f", "http://localhost/"]
Attempts:
3 left
💡 Hint
Common Mistakes
Using plain strings instead of arrays for the test command.
Using RUN instead of CMD in the test array.
3fill in blank
hard

Fix the error in this Dockerfile health check line to correctly specify the command

Docker
HEALTHCHECK CMD [1]
Drag options to blanks, or click blank then click option'
A["RUN", "curl", "-f", "http://localhost/"]
Bcurl -f http://localhost/
C["curl", "-f", "http://localhost/"]
Dcurl http://localhost/
Attempts:
3 left
💡 Hint
Common Mistakes
Using plain strings instead of JSON arrays.
Using RUN in the command array.
4fill in blank
hard

Fill both blanks to create a health check in Docker Compose that retries every 5 seconds and fails after 3 retries

Docker
healthcheck:
  test: [1]
  interval: 5s
  retries: [2]
Drag options to blanks, or click blank then click option'
A["CMD", "curl", "-f", "http://localhost/"]
B10s
C3
Dcurl -f http://localhost/
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string instead of an array for the test command.
Setting retries to a string like '3' instead of a number.
5fill in blank
hard

Fill all three blanks to define a Dockerfile health check with a 30-second timeout, 10-second interval, and 5 retries

Docker
HEALTHCHECK --timeout=[1] --interval=[2] --retries=[3] CMD curl -f http://localhost/
Drag options to blanks, or click blank then click option'
A30s
B10s
C5
D60s
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up timeout and interval values.
Using strings instead of numbers for retries.