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.