Is there any way to disable a service in docker-compose.yml
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
Dockerfilethat 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 ofservices:Sections with the
x-prefix will be parsed, but ignored if not used in the intended way as an extension field.
更多推荐



所有评论(0)