A simple Django ToDo application running with Docker. Just clone, configure, and run with one command.
- Django 5.2 - Web application
- MySQL - Database
- Nginx - Web server
- Docker Compose - Orchestrates everything
django-todo-docker/
├── docker-compose.yml # Main Docker configuration
├── Dockerfile # Django app container
├── nginx/
│ ├── Dockerfile # Nginx container
│ └── default.conf # Nginx configuration
├── todo_project/ # Django project files
├── todo/ # Todo App
├── requirements.txt # Python dependencies
├── .env # Environment variables
├── manage.py
├── .gitignore
└── README.md
git clone https://github.com/amitkumar0128/django-todo-docker.git
cd django-todo-docker
SECRET_KEY=your-secret-key-here
DEBUG=True
DB_NAME=todo_db
DB_USER=todo_user
DB_PASSWORD=supersecret123
DB_HOST=mysql
DB_PORT=3306
MYSQL_ROOT_PASSWORD=rootpassword123
docker-compose up
That's it! 🎉
- Application: http://localhost
- Admin Panel: http://localhost/admin
- 3 containers working together: Django app, MySQL database, Nginx proxy
- Container networking - services communicate internally
- Volume persistence - database data survives container restarts
- Nginx reverse proxy - handles static files and forwards requests
- Gunicorn WSGI server - runs Django in production mode
- Environment variables - secure configuration management
- Health checks - ensures services are running properly
services:
django: # Web application
mysql: # Database
nginx: # Web server
volumes:
mysql-data: # Persistent database storage
networks:
django-net: # Internal container communication
docker-compose ps
docker-compose logs django
docker-compose logs mysql
docker-compose exec django python manage.py createsuperuser
docker-compose down
docker-compose down -v
- Docker Compose reads the configuration and starts 3 containers
- MySQL container starts first and creates the database
- Django container connects to MySQL and runs migrations
- Nginx container starts and proxies requests to Django
- All containers communicate through an internal Docker network
The .env
file keeps sensitive information secure:
- Database passwords
- Django secret key
- Debug settings
- Database connection details
- Docker containerization - packaging applications
- Multi-container orchestration - making services work together
- Environment configuration - managing settings securely
- Production deployment - using proper web servers
- Data persistence - keeping database data safe
Once running, you can:
- Add new ToDo items through the web interface
- Manage data through Django admin panel
- Modify code and see changes reflected
- Scale services by adding more containers
- Deploy to cloud platforms like AWS or DigitalOcean
Perfect for: Learning Docker, Django deployment, or showcasing containerization skills!