
Django & Docker
Dockerfile, docker-compose, multi-stage builds, volumes, networks, development vs production
1Which base image is recommended for a Django application in production?
Which base image is recommended for a Django application in production?
Antwoord
The python:3.x-slim image is recommended as it offers a balance between reduced size and compatibility. It contains essential libraries while avoiding unnecessary dependencies from full images. Alpine images, while lighter, can cause compatibility issues with some compiled Python libraries (like psycopg2).
2What is the main advantage of a multi-stage build for a Django application?
What is the main advantage of a multi-stage build for a Django application?
Antwoord
Multi-stage build significantly reduces the final image size by separating the build environment (with all compilation tools) from the runtime environment. Dependencies are compiled in the first stage, then only necessary files are copied to the final image, excluding build tools, temporary files and caches.
3In a docker-compose.yml, how to ensure the Django container waits until PostgreSQL is ready to accept connections?
In a docker-compose.yml, how to ensure the Django container waits until PostgreSQL is ready to accept connections?
Antwoord
The depends_on directive alone only guarantees container startup, not service availability. To wait until PostgreSQL is actually ready, use a wait-for-it.sh script, dockerize, or the service_healthy condition with a healthcheck. This approach prevents connection errors when the Django application starts.
What is the difference between COPY and ADD in a Dockerfile for a Django application?
How to optimize Docker layer caching when installing Python dependencies?
+17 gespreksvragen
Andere Django-sollicitatieonderwerpen
Python Basics
Python OOP
Django Fundamentals
Django Models - Basics
Django Views
Django Templates
Django Forms
Advanced QuerySets
Django Authentication
Django Middleware
Django Admin
Django REST Framework
Django Signals
File Upload
Django Caching
Django Sessions
Django Email
Django Testing
Django Security
Django Deployment
Advanced Django ORM
Django Performance
Django & Celery
Django Channels
Django & GraphQL
Django in Microservices Ecosystem
Custom Django Commands
Django Internationalization
Django Design Patterns
Django Async & ASGI
Settings & Production Configuration
Observability & Monitoring
Beheers Django voor je volgende gesprek
Krijg toegang tot alle vragen, flashcards, technische tests, code review-oefeningen en gespreksimulatoren.
Begin gratis