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

查看:100
本文介绍了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. docker-compose up client 的所有链接容器中获取输出li>
  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天全站免登陆