Answer a question

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" ?

Answers

You could simply redefine the entrypoint or command 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:

If you don't want the service to get built at all, redefine the build key to point to a Dockerfile that only has:

FROM tianon/true 
ENTRYPOINT ["/true"]

5andr0 points out in the comments the top-level section x-disabled: (an extension field-like)

Far more convenient: moving disabled services to the top-level section x-disabled: instead of services:

Sections with the x- prefix will be parsed, but ignored if not used in the intended way as an extension field.

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐