0
0
Dockerdevops~5 mins

Compose profiles for selective services in Docker - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a Compose profile in Docker Compose?
A Compose profile is a way to group services in a Docker Compose file so you can selectively start those services by enabling specific profiles (services without profiles always start too).
Click to reveal answer
beginner
How do you define a profile for a service in a Docker Compose file?
You add a 'profiles' key under the service with a list of profile names. For example:<br>
services:
  web:
    image: nginx
    profiles:
      - frontend
Click to reveal answer
beginner
How do you start Docker Compose with a specific profile?
Use the command: docker compose --profile <profile_name> up to start services in that profile (in addition to services without profiles).
Click to reveal answer
intermediate
What happens if you run 'docker compose up' without specifying any profile?
Docker Compose starts all services that have no profile specified. Services assigned to profiles are not started unless their profile is enabled.
Click to reveal answer
beginner
Why use Compose profiles for selective services?
Profiles help you manage complex projects by starting only the services you need for a specific task, like development, testing, or production, saving resources and time.
Click to reveal answer
How do you specify a profile for a service in a Docker Compose file?
AAdd a 'profiles' key with a list of profile names under the service
BUse 'profile:' with a single profile name under the service
CAdd 'profile' as an environment variable
DProfiles are set only via command line, not in the file
What command starts services in the 'frontend' profile only?
Adocker compose up frontend
Bdocker compose --profile frontend up
Cdocker compose start frontend
Ddocker compose run frontend
If a service has no profile defined, when does it start?
AAlways, regardless of profiles specified
BOnly with the 'default' profile explicitly enabled
CNever, it must have a profile
DOnly when a profile is specified
Why might you use profiles in Docker Compose?
ATo set network configurations
BTo define environment variables
CTo group services for selective startup
DTo build images automatically
What happens if you run 'docker compose up' with no profiles specified?
ANo services start
BAll services start regardless of profiles
COnly services with profiles start
DOnly services without profiles start
Explain how to use Compose profiles to start only selected services in a Docker Compose project.
Think about grouping services and using command line to select them.
You got /4 concepts.
    Describe the benefits of using Compose profiles in managing Docker services.
    Consider how profiles help organize and control service execution.
    You got /4 concepts.