Artur Keraz’s Post

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

To view or add a comment, sign in

Explore content categories