I find myself in the situation, that I want to disable a service temporarily in a docker-compose
file.
Of course I could comment it out, but is there any option to just say "enabled: false
" ?
To stop a docker application that is running in the foreground, you just have to press Ctrl-C as show above. But, to stop a docker application that is running in the background, use the docker-compose stop as shown below.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With