5 Docker mistakes I see in every Python project I've reviewed dozens of Dockerfiles for Django and FastAPI apps. The same problems keep showing up: 1️⃣ Using python:latest as base image → It's 900MB+. Use python:3.12-slim. Your builds will be 3x faster and your images 4x smaller. 2️⃣ Not using .dockerignore → Your .git folder, __pycache__, .env files — all ending up in the image. Slower builds, potential security risk. 3️⃣ Installing requirements before copying code → Layer caching exists for a reason. Copy requirements.txt first, install deps, THEN copy your code. Every code change won't rebuild all dependencies. 4️⃣ Running as root → Add a non-root user. It takes 2 lines and prevents an entire class of security issues. 5️⃣ No health checks → Your container is "running" but your app crashed 10 minutes ago. Add HEALTHCHECK — let Docker know when something is actually wrong. Fix these five things and your Docker setup goes from "it works on my machine" to production-ready. Which one are you guilty of? 👇 #Docker #Python #DevOps #BackendDevelopment #SoftwareEngineering
What do you think about secrets for local development? I am using them all the time, but just wondering if that`s overengineering or a good practice?
How to do (3) for local development when you need to use shared folders
Up
The Astral-managed py3.13 debian trixie slim image is handy, going to try their 3.14 soonish. Nice to have UV out of the box. Ditched requirements.txt last year, not looked back.