默认情况下Docker-compose排除服务 [英] Docker-compose exclude service by default
问题描述
如果我在docker-compose项目中定义了很多服务,该如何从默认 docker-compose up
命令中排除服务?
If I have a great many services defined in a docker-compose project, how can I exclude a service from the default docker-compose up
command?
例如,我有一个nginx服务和一个ssl服务。它们之所以发生冲突,是因为它们都占用了端口80,因此,如何使它生效,除非我专门运行该服务,否则ssl服务将不会启动,并且默认情况下 up
命令
For example, I have an nginx service, and an ssl service. They conflict because they both consume port 80, so how can I make it so that the ssl service doesn't start unless I specifically run that service, and by default the up
command will do everything EXCEPT the ssl service?
推荐答案
不是您要找的东西,但是您可以使用 scale 标志将您的ssl服务缩放为零:
Not exactly what you're looking for but you could use the scale flag to scale your ssl service to zero:
docker-compose up --scale ssl_service=0
另一种选择是拥有多个撰写文件,并使用 -f
标志运行docker以启动特定服务。
Another option is to have multiple compose files and run docker with the -f
flag to start specific services.
这篇关于默认情况下Docker-compose排除服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!