Everytime I do "docker-compose restart", my initial entered data in the database is automatically removed. I see the data being added to the table but as soon as I do restart or stop the docker and start it again, it doesn't exist anymore. The empty table does exist, It just the data that is deleted. Any help would be greatly appreciated.
docker-compose.yml
version: '3'
services:
app:
build: .
command: python app/manage.py runserver 0.0.0.0:8000
volumes:
- ./:/app/
ports:
- 8000:8000
env_file:
- ./.env.dev
depends_on:
- db
db:
image: postgres
volumes:
- postgres_data:/var/lib/postgresql/data/
environment:
- POSTGRES_USER=cmpt_user
- POSTGRES_PASSWORD=password
- POSTGRES_DB=cmpt_project
volumes:
postgres_data:
Dockerfile
# pull official base image
FROM python:3.8.0-alpine
RUN apk update && apk add postgresql-dev gcc python3-dev musl-dev
# set work directory
WORKDIR /app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install dependencies
RUN pip install --upgrade pip
COPY ./requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt
# copy entrypoint.sh
COPY ./entrypoint.sh /app/entrypoint.sh
# copy project
COPY . /app/
# run entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]