0
0
Dockerdevops~10 mins

Building images 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 specify the build context for the service.

Docker
services:
  web:
    build: [1]
Drag options to blanks, or click blank then click option'
A./app
Bimage: myapp
Cports: 80:80
Dvolumes: ./app:/app
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'image: myapp' under build instead of a path.
Confusing ports or volumes with build context.
2fill in blank
medium

Complete the code to specify the Dockerfile name in the build section.

Docker
services:
  api:
    build:
      context: ./api
      dockerfile: [1]
Drag options to blanks, or click blank then click option'
Arequirements.txt
Bdocker-compose.yml
CDockerfile.api
Dapp.py
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated files like 'app.py' or 'requirements.txt' as Dockerfile.
Using the compose file name instead of Dockerfile.
3fill in blank
hard

Fix the error in the build section to correctly specify the build context and Dockerfile.

Docker
services:
  worker:
    build: [1]
Drag options to blanks, or click blank then click option'
A{ context: ./worker, dockerfile: Dockerfile.worker }
B./worker
Cports: 8080:80
Dimage: worker-image
Attempts:
3 left
💡 Hint
Common Mistakes
Using a simple string when multiple build options are needed.
Confusing image name with build context.
4fill in blank
hard

Fill both blanks to build an image with a custom Dockerfile and tag it.

Docker
services:
  app:
    build:
      context: [1]
      dockerfile: [2]
    image: myapp:latest
Drag options to blanks, or click blank then click option'
A./src
BDockerfile.custom
C./app
DDockerfile
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping context and dockerfile values.
Using default Dockerfile name when a custom one is needed.
5fill in blank
hard

Fill all three blanks to build an image with context, Dockerfile, and build args.

Docker
services:
  backend:
    build:
      context: [1]
      dockerfile: [2]
      args:
        ENV: [3]
Drag options to blanks, or click blank then click option'
A./backend
BDockerfile.prod
Cproduction
DDockerfile.dev
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong Dockerfile for production.
Confusing build args with environment variables.