Setting Up a Simple Docker Development Environment

Here’s my learning journey setting up a Django development environment with Docker:

I needed a consistent dev environment without Windows dependency issues, but didn’t want to switch between Linux/Windows or buy a Mac. Docker seemed perfect.

Basic setup was quick - had Django running in 10 minutes. The learning curve came with customization:

My requirements:

  • Django container
  • PostgreSQL container
  • Auto-migrations on rebuild

The first two were straightforward using Docker docs. The challenge came with automating migrations.

Key issue: Docker containers don’t build sequentially. Solution required:

  1. depends_on: Declare service dependencies
depends_on:
    - postgres
  1. health_check: Verify database readiness
depends_on:
    postgres:
        condition: service_healthy
  1. Database connection check:
psql -h localhost -p 5432 -U postgres_usr -d postgres_db

Now I have a one-command development setup. Planning to practice with other frameworks to improve this workflow.

— UTQ —

Posts in this series