You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mounts the local config file into Nginx. :ro means read-only — Nginx cannot modify it
static_volume:/vol/static:ro
Shares the same volume as web. Nginx serves static files directly without going through Django
depends_on: web
Starts after the web container (though this is a soft dependency — doesn't wait for Django to be ready)
Volumes
volumes:
postgres_data:
static_volume:
Named volumes managed by Docker:
Volume
Purpose
postgres_data
Persists the PostgreSQL database files between restarts
static_volume
Shared between web (writes) and nginx (reads) for static assets
Key Difference from Production
The main difference in dev is build: . vs image: — dev builds the image locally from source, production pulls a pre-built image from Docker Hub. Also in dev, Nginx binds directly to port 80 on the host (ports: "80:80"), whereas in production it uses expose only and sits behind a shared proxy.
Common Commands
# Start everything
docker compose up -d
# Rebuild after code changes
docker compose up -d --build
# View logs
docker compose logs -f web
# Stop and remove containers (keeps volumes)
docker compose down
# Stop and remove containers AND volumes (wipes database)
docker compose down -v
# Run a Django management command
docker exec -it blog_django python manage.py createsuperuser