0
0
Dockerdevops~5 mins

Defining services in Docker - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a service in Docker Compose?
A service in Docker Compose is a container configuration that defines how a container should run, including the image, ports, volumes, and environment variables.
Click to reveal answer
beginner
Which file is used to define services in Docker Compose?
Services are defined in the docker-compose.yml file using YAML syntax.
Click to reveal answer
beginner
How do you specify the image for a service in Docker Compose?
Use the image key under the service name to specify the Docker image to use, for example: image: nginx:latest.
Click to reveal answer
beginner
What is the purpose of the ports key in a service definition?
The ports key maps container ports to host machine ports, allowing access to the service from outside the container.
Click to reveal answer
beginner
How can you define environment variables for a Docker Compose service?
Use the environment key under the service to list environment variables as key-value pairs.
Click to reveal answer
Where do you define services in Docker Compose?
AIn the docker-compose.yml file
BIn the Dockerfile
CIn the .env file
DIn the docker CLI command
Which key specifies the Docker image for a service?
Aimage
Bbuild
Ccontainer
Dservice
What does the 'ports' key do in a service definition?
ASets environment variables
BSpecifies the network
CDefines volumes
DMaps container ports to host ports
How do you add environment variables to a service?
AUsing the 'env' key
BUsing the 'environment' key
CUsing the 'variables' key
DUsing the 'config' key
Which file format is used for Docker Compose service definitions?
AJSON
BXML
CYAML
DINI
Explain how to define a simple web service in Docker Compose.
Think about the minimum keys needed to run a web server container.
You got /4 concepts.
    Describe the role of environment variables in Docker Compose services and how to set them.
    Consider how environment variables customize container behavior.
    You got /3 concepts.