All chapters

Chapter 9: Docker Performance Tips

In this chapter, uncover practical Docker optimizations for faster Python app builds and deployments. Learn how to reorder Dockerfile commands to leverage layer caching—so small changes (like editing a CSS file) won’t trigger full dependency reinstalls. Explore uv, a tool that quickly fetches Python versions and caches dependencies, while Docker’s --mount option preserves these caches across rebuilds. You’ll also see how a .dockerignore file trims out unneeded files, speeding up image builds. Finally, discover strategies for improving continuous integration times and reducing PyPI overhead, all while creating smaller, more efficient Docker images for your production environment.

Buy the full book to get this chapter
Next up: Chapter 10: NGINX, Containers, and Let's Encrypt
Talk Python's Mastodon Michael Kennedy's Mastodon