docker-compose up仅适用于某些容器 [英] docker-compose up for only certain containers
问题描述
我有一个 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:
- 告诉docker-compose应该由
docker-compose up
- 从
docker-compose up client
的所有链接容器中获取输出li>
- Tell docker-compose which containers should by started by
docker-compose up
- 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屋!