docker-compose start "ERROR: No containers to start"

DockerDocker Compose

Docker Problem Overview


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?

Docker Solutions


Solution 1 - Docker

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.

Solution 2 - Docker

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPrichmpView Question on Stackoverflow
Solution 1 - DockerJesusTinocoView Answer on Stackoverflow
Solution 2 - DockerPhilipp ClaßenView Answer on Stackoverflow