Recall & Review
beginner
What is the purpose of the
version key in a docker-compose.yml file?The
version key specifies the Compose file format version. It tells Docker Compose which syntax rules to follow when reading the file.Click to reveal answer
beginner
What does the
services section define in a docker-compose.yml file?The
services section lists all the containers (services) that Docker Compose will create and manage. Each service has its own configuration like image, ports, and environment variables.Click to reveal answer
intermediate
In
docker-compose.yml, what is the role of the volumes key under a service?The
volumes key connects storage from the host machine or named volumes to the container, allowing data to persist or be shared between containers.Click to reveal answer
beginner
How do you specify which ports to expose from a container in
docker-compose.yml?Use the
ports key under a service. It maps host ports to container ports in the format host_port:container_port.Click to reveal answer
beginner
What is the purpose of the
environment section in a docker-compose.yml service?The
environment section sets environment variables inside the container. These variables can configure the app or service running inside.Click to reveal answer
Which key in
docker-compose.yml defines the containers to run?✗ Incorrect
The
services key lists all containers Docker Compose will create.How do you map port 8080 on your computer to port 80 in the container?
✗ Incorrect
The format is
host_port:container_port, so 8080:80 maps host port 8080 to container port 80.What does the
volumes key do in a service definition?✗ Incorrect
Volumes connect storage from the host or named volumes to containers for data persistence.
Where do you specify environment variables for a container in
docker-compose.yml?✗ Incorrect
The
environment key sets environment variables inside the container.What is the correct file format for
docker-compose.yml?✗ Incorrect
docker-compose.yml uses YAML format, which is easy to read and write.Describe the main sections of a
docker-compose.yml file and their purposes.Think about what each part controls in running containers.
You got /5 concepts.
Explain how you would expose a web app running on port 80 inside a container to port 3000 on your computer using
docker-compose.yml.Remember the format is host_port:container_port.
You got /3 concepts.