Rusty Shackleford Rusty Shackleford - 4 months ago 483
YAML Question

Using Docker-Compose, how to execute multiple commands

I want to do something like this where I can run multiple commands in order.

db:
image: postgres
web:
build: .
command: python manage.py migrate
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
links:
- db

Answer

Figured it out, use bash -c

example:

command: bash -c "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"