I am new to Django and have been playing with the following tutorial:
https://testdriven.io/blog/dockerizing-django-with-postgres-gunicorn-and-nginx/
When I am running the production example towards the end, users I ad via the admin interface don’t seem to persist if I rerun the docker container even though a volume is created for the postgres data. Any ideas?
version: '3.7'
services:
web:
build:
context: ./app
dockerfile: Dockerfile.prod
command: gunicorn hello_django.wsgi:application --bind 0.0.0.0:8000
volumes:
- static_volume:/home/app/web/staticfiles
- media_volume:/home/app/web/mediafiles
expose:
- 8000
env_file:
- ./.env.prod
depends_on:
- db
db:
image: postgres:12.0-alpine
volumes:
- postgres_data:/var/lib/postgresql/data/
env_file:
- ./.env.prod.db
nginx:
build: ./nginx
volumes:
- static_volume:/home/app/web/staticfiles
- media_volume:/home/app/web/mediafiles
ports:
- 1337:80
depends_on:
- web
volumes:
postgres_data:
static_volume:
media_volume:
Here is a link to the project:
https://github.com/testdrivenio/django-on-docker