0
0
Dockerdevops~5 mins

docker-compose.yml structure - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Avolumes
Bnetworks
Cservices
Dimages
How do you map port 8080 on your computer to port 80 in the container?
Aports: - "8080:80"
Bports: - "80"
Cports: - "8080"
Dports: - "80:8080"
What does the volumes key do in a service definition?
ASets environment variables
BConnects storage between host and container
CDefines network settings
DSpecifies container image
Where do you specify environment variables for a container in docker-compose.yml?
Aunder <code>environment</code> key
Bunder <code>ports</code> key
Cunder <code>volumes</code> key
Dunder <code>networks</code> key
What is the correct file format for docker-compose.yml?
AJSON
BXML
CINI
DYAML
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.