Is there any way to disable a service in docker-compose.yml

As of January 2021, there is a way to elegantly disable a service within the docker-compose.yml or to selectively run some services and not others. Docker Compose 1.28.0 introduced support for a profiles key. Now we can do something like:

version: "3.9"
services:
  base_image:
    ...
    profiles:
      - donotstart

Examples in the documentation describe how to use this key to create groups of containers that run together based on a --profile option on the command line. Check out the page here: https://docs.docker.com/compose/profiles/

Update

Support for profiles is working correctly in Compose V2 beta 5 (docker compose). Compose V2 beta 6 has been included in Docker Desktop 3.5.2 released 2021-07-08.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)