0
0
Dockerdevops~10 mins

Environment files (.env) 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 load environment variables from a file named .env in Docker Compose.

Docker
services:
  app:
    env_file: [1]
Drag options to blanks, or click blank then click option'
Avariables.env
Bconfig.env
C.env
Denv.list
Attempts:
3 left
💡 Hint
Common Mistakes
Using a filename without the leading dot.
Confusing env_file with environment variables set directly.
2fill in blank
medium

Complete the .env file line to set the variable PORT to 8080.

Docker
PORT=[1]
Drag options to blanks, or click blank then click option'
A80
B8080
C8000
D443
Attempts:
3 left
💡 Hint
Common Mistakes
Adding quotes around the number.
Using a different port number.
3fill in blank
hard

Fix the error in this .env line to correctly set the variable DEBUG to true.

Docker
DEBUG=[1]
Drag options to blanks, or click blank then click option'
Atrue
B"true"
CTRUE
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using capitalized or quoted boolean values.
Leaving spaces around the equals sign.
4fill in blank
hard

Fill both blanks to create a .env line that sets the variable API_KEY to a secret value.

Docker
API_KEY=[1][2]
Drag options to blanks, or click blank then click option'
A12345
Babcdef
C"
D'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes for string values.
Using single quotes which may cause issues.
5fill in blank
hard

Fill all three blanks to write a Docker Compose environment section that uses the .env file and overrides PORT to 5000.

Docker
services:
  web:
    env_file: [1]
    environment:
      - PORT=[2]
      - DEBUG=[3]
Drag options to blanks, or click blank then click option'
A.env
B5000
Ctrue
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong filenames for env_file.
Setting PORT or DEBUG with wrong values or formats.