Complete the code to specify the version of Docker Compose file format.
version: '[1]' services: web: image: myapp:latest
The version field in Docker Compose specifies the file format version. '3.8' is a commonly used stable version for modern Docker Compose files.
Complete the code to define a service named 'db' using the official PostgreSQL image.
services:
db:
image: [1]The db service uses the official PostgreSQL image tagged 'postgres:13' for version 13.
Fix the error in the environment variable syntax for the 'web' service.
services:
web:
image: myapp:latest
environment:
- DATABASE_URL=[1]Environment variable values with special characters should be quoted with double quotes in YAML to avoid parsing errors.
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.
services:
web:
ports:
- '[1]:[2]'
volumes:
- './:[3]'Port mapping uses 'host_port:container_port' format, so '8080:80' maps local 8080 to container 80. Volume mounts map local './' to container '/app' to share code.
Fill all three blanks to define a 'depends_on' relationship where 'web' depends on 'db', and set restart policy to always.
services:
web:
depends_on:
- [1]
restart: [2]
db:
image: postgres:13
restart: [3]The 'web' service depends on 'db' to start first. Setting 'restart: always' ensures services restart automatically on failure.