Compose profiles for selective services
š Scenario: You are managing a small web application with multiple services. You want to run only specific services depending on the environment, like development or production, using Docker Compose profiles.
šÆ Goal: Learn how to create a docker-compose.yml file with profiles to selectively start services. You will define services and assign them to profiles, then run only the services for a chosen profile.
š What You'll Learn
Create a
docker-compose.yml file with three services: web, db, and cacheAssign the
web and db services to the prod profileAssign the
web and cache services to the dev profileUse the
profiles key in the compose file to specify profilesRun
docker compose --profile dev up to start only the dev profile servicesš” Why This Matters
š Real World
In real projects, you often want to run only some services depending on the environment, like running a cache only in development but not in production.
š¼ Career
Knowing how to use Docker Compose profiles helps you manage complex applications efficiently and is a valuable skill for DevOps and software engineers.
Progress0 / 4 steps