version: '2'
services:
  todolist:
    image: todolist
    restart: always
    env_file: .env
    command: gunicorn todolist:app -w 2 -b :8000
    ports:
      - "8000:8000"
    depends_on:
      - migration

  migration:
    build: .
    image: todolist
    env_file: .env
    command: flask db upgrade
    volumes:
      - .:/code

version: '2'
services:
  todolist:
    container_name: todolist
    image: todolist
    # restart: always
    env_file: .env
    command: gunicorn todolist:app -w 2 -b :8000
    ports:
      - "8000:8000"
    depends_on:
      - migration

  migration:
    container_name: migration
    build: .
    image: todolist
    env_file: .env
    command: flask db upgrade
    volumes:
      - .:/code

Add container_name for docker services
Add container_name for docker services

Comment out automatic restart, which is more useful in a production
context
