使用Docker-Compose,如何执行多个命令
问题描述:
我想做这样的事情,我可以按顺序运行多个命令。
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
答
使用 bash -c
示例:
command: bash -c "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"