Reputation: 2292
I am trying to use Docker Compose (with Docker Machine on Windows) to launch a group of Docker containers.
My docker-compose.yml:
version: '2'
services:
postgres:
build: ./postgres
environment:
- POSTGRES_PASSWORD=mysecretpassword
frontend:
build: ./frontend
ports:
- "4567:4567"
depends_on:
- postgres
backend:
build: ./backend
ports:
- "5000:5000"
depends_on:
- postgres
docker-compose build
runs successfully. When I run docker-compose start
I get the following output:
Starting postgres ... done
Starting frontend ... done
Starting backend ... done
ERROR: No containers to start
I did confirm that the docker containers are not running. How do I get my containers to start?
Upvotes: 153
Views: 89976
Reputation: 44019
The reason why you saw the error is that docker-compose start
and docker-compose restart
assume that the containers already exist.
If you want to build and start containers, use
docker-compose up
If you only want to build the containers, use
docker-compose up --no-start
Afterwards, docker-compose {start,restart,stop}
should work as expected.
There used to be a docker-compose create
command, but it is now deprecated in favor of docker-compose up --no-start
.
Upvotes: 50
Reputation: 11828
The issue here is that you haven't actually created the containers. You will have to create these containers before running them. You could use the docker-compose up
instead, that will create the containers and then start them.
Or you could run docker-compose create
to create the containers and then run the docker-compose start
to start them.
Upvotes: 238