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:
- Tell docker-compose which containers should by started by
docker-compose up
- Get output from all linked containers from
docker-compose up client
To start a particular service defined in your docker-compose file. for example if your have a docker-compose.yml
given a compose file like as:
Some times you want to start mySQL only (sometimes you just want to populate a database) before you start your entire suite.
You usually don't want to do this. With Docker Compose you define services that compose your app.
npm
andmanage.py
are just management commands. You don't need a container for them. If you need to, say create your database tables withmanage.py
, all you have to do is:Think of it as the one-off dynos Heroku uses.
If you really need to treat these management commands as separate containers (and also use Docker Compose for these), you could create a separate
.yml
file and start Docker Compose with the following command:You can start containers by using:
This will run containers in the background and output will be avaiable from
and it will consist of all your started containers