Docker-compose allow the user want to execute multiple commands at the time in a Docker-compose.yaml file. There are two ways to do this, either using sh or bash.
The below commands are used to execute the multiple commands at a time in a docker-compose.yml file.
Option 1:
command: >
bash -c "python my_manage.py migrate
&& python my_manage.py runserver 0.0.0.0:8080"
Option 2:
command: bash -c "
python my_manage.py migrate
&& python my_manage.py runserver 0.0.0.0:8080
"
so, you the docker-compose.yml file would be,
version: '3'
services:
app:
build:
context: .
command: >
bash -c "python my_manage.py migrate
&& python my_manage.py runserver 0.0.0.0:8080"
python my_manage.py migrate - run any migrations
python my_manage.py runserver 0.0.0.0:8080 - start your application in docker container
Comments (0)