您可以定义可选的docker-compose服务吗? [英] Can you define optional docker-compose services?

查看:80
本文介绍了您可以定义可选的docker-compose服务吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以定义Docker Compose服务,以便仅在您明确请求时才将它调高



也就是说:

  docker-组成

不会启动它,但是

  docker-compose up optional_service 

将。

解决方案

一种实现方法是在其他撰写文件中定义可选服务。然后启动可选服务,运行:

  $ docker-compose -f docker-compose.yml -f选项服务。 yaml up 

例如,如果我有一个docker-compose.yml文件,如下所示:

 版本: 2.1 
服务:
lb:
图片:nginx:1.13
db:
图像:redis:3.2.9

我可以使用看起来像这样的optional-service.yml:

 版本: 2.1 
服务:
忙碌状态:
图片:busybox

请注意,两个撰写文件必须使用相同的撰写文件版本。 / p>

您可以在撰写文档中了解有关此内容的更多信息


Is there a way to define a Docker Compose service such that it is only brought up when you explicitly request it?

That is to say:

docker-compose up

would not start it, but

docker-compose up optional_service

would.

解决方案

One way to achieve that is to define your optional service in a different compose file. Then to start the optional service, run:

$ docker-compose -f docker-compose.yml -f optional-service.yaml up

For example, if I have a docker-compose.yml file that looks like:

version: '2.1'
services:
  lb:
    image: nginx:1.13           
  db:
    image: redis:3.2.9

I can extend it with an optional-service.yml that looks like:

version: '2.1'
services:
  busy:
    image: busybox

Notice that both compose files must use the same Compose file version.

You can read more about it in the Compose documentation.

这篇关于您可以定义可选的docker-compose服务吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆