Have you failed a job interview?
Send us your job interview questions and get correct answers.

What are Docker Compose profiles good for?

Experience Level: Senior
Tags: Docker Compose

Answer

You can assign Docker Compose services to profiles. Later when you are starting services, you can define which profile to use. If you pass a profile, only services that belong to a specified profile will be used.

version: "3.9"
services:
  frontend:
    image: frontend
    profiles: ["frontend"]
  healthcheck:
    image: busybox
    profiles: ["frontend"]
  phpmyadmin:
    image: phpmyadmin
    depends_on:
      - db
    profiles:
      - debug

Here the services frontend and healthcheck are assigned to the profiles frontend. You can run services from this profile by running the following command:

docker compose --profile frontend up

Comments

No Comments Yet.
Be the first to tell us what you think.
Docker Compose
Docker Compose

Are you learning Docker Compose ? Try our test we designed to help you progress faster.

Test yourself