0
0
Microservicessystem_design~10 mins

Docker Compose for local development in Microservices - 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.

Microservices
version: '[1]'
services:
  web:
    image: myapp:latest
Drag options to blanks, or click blank then click option'
Alatest
B3.8
Cv2
D1.0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'latest' as version causes errors.
Using 'v2' is not a valid version string here.
2fill in blank
medium

Complete the code to define a service named 'db' using the official PostgreSQL image.

Microservices
services:
  db:
    image: [1]
Drag options to blanks, or click blank then click option'
Aredis:6
Bmysql:latest
Cpostgres:13
Dmongo:4.4
Attempts:
3 left
💡 Hint
Common Mistakes
Using MySQL or MongoDB images for a PostgreSQL service.
Omitting the version tag may cause unexpected updates.
3fill in blank
hard

Fix the error in the environment variable syntax for the 'web' service.

Microservices
services:
  web:
    image: myapp:latest
    environment:
      - DATABASE_URL=[1]
Drag options to blanks, or click blank then click option'
A"postgres://user:pass@db:5432/mydb"
Bpostgres://user:pass@db:5432/mydb
C'postgres://user:pass@db:5432/mydb'
DDATABASE_URL=postgres://user:pass@db:5432/mydb
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the URL causes YAML parsing errors.
Using single quotes may work but double quotes are safer here.
4fill in blank
hard

Fill both blanks to correctly map the local port 8080 to the container port 80 and mount the current directory to /app inside the container.

Microservices
services:
  web:
    ports:
      - '[1]:[2]'
    volumes:
      - './:[3]'
Drag options to blanks, or click blank then click option'
A8080
B80
C/app
D/var/www
Attempts:
3 left
💡 Hint
Common Mistakes
Reversing port mapping order.
Mounting to wrong container directory.
5fill in blank
hard

Fill all three blanks to define a 'depends_on' relationship where 'web' depends on 'db', and set restart policy to always.

Microservices
services:
  web:
    depends_on:
      - [1]
    restart: [2]
  db:
    image: postgres:13
    restart: [3]
Drag options to blanks, or click blank then click option'
Adb
Balways
Cno
Dnever
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong service name in depends_on.
Setting restart policy to 'no' disables auto-restart.