docker-compose up 仅适用于某些容器 [英] docker-compose up for only certain containers

查看:20
本文介绍了docker-compose up 仅适用于某些容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个容器的 docker-compose.yml.其中三个用于我的应用程序(客户端、服务器和数据库),其余用于各种开发工具(例如 psql、npm、manage.py 等).当我执行 docker-compose up 时,所有这些都已启动,但我只想启动三个主要的.由于我指定的链接,我可以使用 docker-compose up client 启动这三个,但输出仅来自那个容器.那么,有没有办法执行以下操作之一:

I have a docker-compose.yml which contain several containers. Three of them are for my app (client, server and database) and the rest are for various dev tools (e.g. psql, npm, manage.py, etc). When I do docker-compose up all of them are started, but I only want the three main ones to start. Because of the links I've specified, I can start just those three with docker-compose up client but then the output is only from that one container. So, is there a way to do one of the following:

  1. 告诉 docker-compose 哪些容器应该由 docker-compose up
  2. 启动
  3. docker-compose up client 获取所有链接容器的输出
  1. Tell docker-compose which containers should by started by docker-compose up
  2. Get output from all linked containers from docker-compose up client

推荐答案

您可以使用以下方式启动容器:

You can start containers by using:

$ docker-compose up -d client

这将在后台运行容器,输出可从

This will run containers in the background and output will be avaiable from

$ docker-compose logs

它将包含您所有启动的容器

and it will consist of all your started containers

这篇关于docker-compose up 仅适用于某些容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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