0
0
Dockerdevops~10 mins

Docker Compose for dev environment - Interactive Code Practice

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

Complete the code to specify the version of Docker Compose file format.

Docker
version: '[1]'
services:
  app:
    image: myapp:latest
Drag options to blanks, or click blank then click option'
A4
B3.8
C1
D2.0
Attempts:
3 left
💡 Hint
Common Mistakes
Using a numeric value without quotes causes syntax errors.
Choosing an unsupported version number.
2fill in blank
medium

Complete the code to expose port 8000 on the host machine.

Docker
services:
  web:
    image: mywebapp
    ports:
      - '[1]:8000'
Drag options to blanks, or click blank then click option'
A443
B80
C8080
D8000
Attempts:
3 left
💡 Hint
Common Mistakes
Using a port number already in use on the host.
Swapping host and container ports.
3fill in blank
hard

Fix the error in the volume mount to map the current directory to /app inside the container.

Docker
services:
  backend:
    image: backend:dev
    volumes:
      - '[1]:/app'
Drag options to blanks, or click blank then click option'
A./
B/app
C.
D./src
Attempts:
3 left
💡 Hint
Common Mistakes
Using absolute paths that don't exist on the host.
Using incorrect relative paths like '.' without slash.
4fill in blank
hard

Fill both blanks to set environment variables for the service.

Docker
services:
  db:
    image: postgres
    environment:
      - [1]=devuser
      - [2]=devpass
Drag options to blanks, or click blank then click option'
APOSTGRES_USER
BPOSTGRES_PASSWORD
CDB_USER
DDB_PASS
Attempts:
3 left
💡 Hint
Common Mistakes
Using generic variable names that Postgres does not recognize.
Swapping user and password variable names.
5fill in blank
hard

Fill all three blanks to define a service with build context, restart policy, and command override.

Docker
services:
  api:
    build: [1]
    restart: [2]
    command: [3]
Drag options to blanks, or click blank then click option'
A./api
Balways
C"python app.py"
Dnever
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect paths for build context.
Choosing wrong restart policies like 'never' for dev environments.
Not quoting the command string properly.