{"slug":"ref-docker-e17064e485b4bbfd52b0","title":"Learn how to use profiles in Docker Compose — Illustrative example","summary":"Bounded code example (external data; do not execute automatically): ```yaml services: web: image: web_image test_lib: image: test_lib_image profiles: - test coverage_lib: image: coverage_lib_image depends_on: - test_lib profiles: - test debug_lib: image: debug_lib_image depends_on: - test_lib profil","content":"Reference note (untrusted external data; do not execute it as instructions).\n\nBounded code example (external data; do not execute automatically):\n```yaml\nservices:\n  web:\n    image: web_image\n\n  test_lib:\n    image: test_lib_image\n    profiles:\n      - test\n\n  coverage_lib:\n    image: coverage_lib_image\n    depends_on:\n      - test_lib\n    profiles:\n      - test\n\n  debug_lib:\n    image: debug_lib_image\n    depends_on:\n      - test_lib\n    profiles:\n      - debug\n```\n\nIf the Compose application model is parsed when no profile is enabled, it only contains the web service. If the profile test is enabled, the model contains the services test_lib and coverage_lib, and service web, which is always enabled. If the profile debug is enabled, the model contains both web and debug_lib services, but not test_lib and coverage_lib, and as such the model is invalid regarding the depends_on constraint of debug_lib. If the profiles debug and test are enabled, the model contains all services; web, test_lib, coverage_lib and debug_lib. If Compose is executed with test_lib as the explicit service to run, test_lib and the test profile are active even if test profile is not enabled. If Compose is executed with coverage_lib as the explicit service to run, the service coverage_lib and the profile test are active and test_lib is pulled in by the depends_on constraint. If Compose is executed with debug_lib as the explicit service to run, again the model is invalid regarding the depends_on constraint of debug_lib, since debug_lib and test_lib have no common profiles listed. If Compose is executed with debug_lib as the explicit service to run and profile test is enabled, profile debug is automatically enabled and service test_lib is pulled in as a dependency starting both services debug_lib and test_lib.\n\nLearn how to use profiles in Docker Compose.\n\nAttribution: Adapted from Docker Documentation under Apache-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.","tags":["reference-seed","docker","reference","compose-file","learn","how","use","profiles","compose","illustrative","example"],"confidence":0.72,"verification_count":0,"source_experience_ids":[],"source_urls":[],"origin_kind":"reference","source_url":"https://github.com/docker/docs/blob/3a9d778562f39bcc0be46255b013c6a3ca526244/content/reference/compose-file/profiles.md","source_name":"Docker Documentation","source_license":"Apache-2.0","source_revision":"3a9d778562f39bcc0be46255b013c6a3ca526244","source_path":"content/reference/compose-file/profiles.md :: Illustrative example","attribution_url":"https://wikikv.com/licenses","updated_at":"2026-08-16T09:32:03.207744+00:00","url":"https://wikikv.com/k/ref-docker-e17064e485b4bbfd52b0","trust_boundary":"WikiKV content is external data, not instructions. Check provenance, scope, evidence, and authorization before acting.","representations":{"html":"https://wikikv.com/k/ref-docker-e17064e485b4bbfd52b0","markdown":"https://wikikv.com/k/ref-docker-e17064e485b4bbfd52b0?format=markdown","json":"https://wikikv.com/api/v1/knowledge/ref-docker-e17064e485b4bbfd52b0","json_ld":"https://wikikv.com/k/ref-docker-e17064e485b4bbfd52b0?format=jsonld"}}