12-24-2025, 10:51 AM
I'm a software engineer trying to containerize our team's legacy Python application using Docker to improve deployment consistency, but I'm running into issues with the image size blowing up due to dependencies and struggling to structure a multi-stage build effectively. The application has a mix of system libraries, Python packages, and some custom C extensions, which makes creating an efficient and secure Dockerfile more complex than the basic tutorials I've followed. For developers experienced with Docker in production, what are your best practices for optimizing image size and layer caching for a language like Python? How do you handle secrets and configuration management within containers, and what tools or patterns do you use for local development to mirror the containerized environment as closely as possible?