I have a docker django postgres project.
docker-compose.yml:
version: '3'
services:
web:
build: .
command: bash -c "python manage.py migrate && python manage.py load_patient_data && python manage.py runserver 0.0.0.0:8000"
ports:
- 8000:8000
depends_on:
- db
db:
image : postgres
restart: always
environment:
- "POSTGRES_HOST_AUTH_METHOD=trust"
Dockerfile:
FROM python:3
ENV PYTHONUNBUFFERED 1
WORKDIR /app
ADD . /app
COPY ./requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt
COPY . /app
After I run:
docker-compose up
It returns:
db_1 | 2021-11-23 03:00:08.204 UTC [62] LOG: database system was shut down at 2021-11-23 03:00:08 UTC
db_1 | 2021-11-23 03:00:08.209 UTC [1] LOG: database system is ready to accept connections
And will handle on there.
This time if I control+c and run:
docker-compose up
again, it will work. Or if I go to the docker app and manually start the container, it will also work.
What should I do, to let the container run automatically just by running:
docker-compose up