Complete the code to start all services defined in a Docker Compose file.
docker-compose [1]The docker-compose up command starts all the services defined in the docker-compose.yml file, making it easy to run multi-container apps with one command.
Complete the code to define a service named 'web' in a Docker Compose YAML file.
services:
web:
image: nginx
ports:
- "80:[1]"Port mapping 80:80 means the host's port 80 maps to the container's port 80, which is the default HTTP port for nginx.
Fix the error in the Docker Compose command to rebuild images before starting containers.
docker-compose [1] --buildThe docker-compose up --build command rebuilds images before starting containers, which is useful after changing Dockerfiles.
Fill both blanks to define a volume named 'db-data' and mount it to '/var/lib/mysql' in the 'db' service.
services:
db:
image: mysql
volumes:
- [1]:[2]Volumes are named storage areas. Here, 'db-data' is the volume name, and '/var/lib/mysql' is the path inside the container where MySQL stores data.
Fill all three blanks to define a network named 'app-net', attach 'web' and 'db' services to it in Docker Compose.
networks: [1]: services: web: image: nginx networks: - [2] db: image: mysql networks: - [3]
Defining a network 'app-net' and attaching both 'web' and 'db' services to it allows them to communicate easily.