Running with Docker Compose

Running the Django app and database with Docker Compose

Want more?

This lesson for enrolled students only. Join the course to unlock it!

You can see the code changes implemented in this lecture below.

If you have purchased the course in a different platform, you still have access to the code changes per lecture here on Teclado. The lecture video and lecture notes remain locked.
Join course for $15

New files

docker-compose.yml
name: djangocourse-local
services:
  db:
    image: postgres
    env_file:
      - ./.env.docker
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}
      interval: 2s
      timeout: 10s
      retries: 5
      start_period: 30s
  web:
    build:
      context: .
      dockerfile: Dockerfile
    init: true
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    env_file:
      - ./.env.docker
    restart: unless-stopped
    depends_on:
      db:
        condition: service_healthy
volumes:
  postgres_data: