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
" ?
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
" ?
There is no way to disable a service defined in Docker compose yaml file. VonC's suggestion is a good workaround Please see below the docker compose documentation for available options https://docs.docker.com/compose/compose-file/
I would scale the service to 0 replicas with: deploy: replicas: 0
Unfortunately as the documentation states this only works with docker swarm.
I add the following extra line to the service I want to temporarily disable:
It starts anyway, but does nothing.
You can do it in a
docker-compose.override.yaml
file.This file is automatically read by
docker-compose
and merged into the maindocker-compose.yaml
.If you have it excluded from Git, each developer can tweak the configuration (with a few limitations) without changing the original
docker-compose.yaml
.So, service
foo
can be disabled ad-hoc by redefining its entrypoint indocker-compose.override.yaml
:You could simply redefine the
entrypoint
orcommand
in order to replace said command with something which does nothing (/bin/true
)That would make the container exit immediately, doing nothing.
shadi adds the following tips in the comments: