How do you debug your broken Docker build?

There are many technologies you need to learn as a Python programmer: learning Docker is just one more item on an ever-expanding list. So when you’ve used it before, you learned just enough command-line basics to get your work done.

But now you need to start packaging your application, which means doing everything from from writing Dockerfiles to debugging broken builds—and your basic knowledge isn’t enough.

  • How do you debug a docker: Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"flask\": executable file not found in $PATH": unknown.?
  • Why are you wasting time re-running pip install, downloading and re-installing every single package, every single time?
  • Why are you getting a connection reset error when you try to point your browser at your Dockerized application?

You need to actually understand how Docker packaging works, and quickly; you still have plenty of other work to do.

The two things you need to know

You want to use Docker effectively in the real world, to package real Python applications. And you want to get to work quickly and with confidence.

You can do that by learning and then combining two distinct types of knowledge:

  1. An intuitive mental model of how Docker packaging works. With a good mental model, you can learn the details if and when you need them.
  2. The specific debugging and problem-solving facilities provided by Docker. With good debugging tools, you can solve your problems when things inevitably break.

Get up and running quickly

To help you build that intuitive mental model, and learn those debugging skills, I’ve written a concise, practical, developer-focused book: Just Enough Docker Packaging.

This book will show you how Docker packaging actually works, with shell transcripts, plenty of examples, conceptual diagrams, and exercises to help you practice what you’ve learned. Occasionally I’ll even make a mistake, so you can see how I recover.

What readers are saying:

The debugging section was super useful, in its entirety. Besides that, the overall or high-level concepts and how you presented them visually really helped.

I have been using Docker for 2 years maybe, as a developer, and I understood the mechanics, but I did not have time to really think about the details or understand how the images where composed.

The book was really useful to me. I am grateful to you for putting this together.

—Pablo Oliva

As you read the book, you’ll learn just enough about Docker packaging to get to work, including:

  • The Dockerfile format.
  • The image format.
  • The semantics of naming and tagging images.
  • The image cache.
  • The Docker build process that ties these all together.

And since that’s a lot to cover, and you want to get going as quickly as possible, the book won’t teach you every little detail. Which means you can get through it in an afternoon at work, and then refer back to it as needed.

Just Enough Docker Packaging assumes:

  1. You’re running on a Mac or Linux.
  2. You have some familiarity with command-line tools and the Unix shell.
  3. You have a minimal understanding of Python packaging.
  4. Minimal to zero previous knowledge of Docker.

Ready to learn Docker packaging, quickly and effectively?

What readers are saying:

“Thank you. Your book really helped. I’ve been working with Docker for a few years now and I found the debugging techniques - especially copying files in and out of the container - to be really interesting and immediately useful. I didn’t know these capabilities existed.

I would definitely recommend the book to a colleague if they were trying to get started with Docker or improve their knowledge.

—Alexander Kammerer, Investment Engineer

Just Enough Docker Packaging Production best practices bundle
  • Concise, focused PDF book, last updated in April 2020.
  • Exercises to solidify your understanding.
  • All updates to the 1st edition.
  • 100% money-back guarantee.
  • Everything in the book.
  • Plus, the ~40 page Python on Docker Production Checklist.
  • 35 different best practices for packaging Python applications for production, from security to reproducibility to build time.
  • Extensive examples and additional references.
  • All updates to the 1st edition.
  • 100% money-back guarantee.

Want to buy the book for your whole team? Buy a 10-person license for US$199.

Note: I prefer not to take money from teams working on projects for the military, prisons, fossil fuel extraction, surveillance, national security, or the like. If that applies to you, please don’t purchase this product.

What’s in the book

Chapter by chapter, Just Enough Docker Packaging covers:

  1. Images and containers: what they are and how to use them.
  2. Minimal packaging: your first Docker image for a simple Python application, and the basics of Dockerfile commands.
  3. Docker networking and its impact on packaging: configuring servers, and finding addresses as client software via environment variables and well-known hostnames.
  4. Configuring your application for Docker packaging: persistent data, logging, volumes, command-line parsing.
  5. Sharing images: pulling and pushing, image registries, and understanding image naming.
  6. Smaller and faster builds: build caching, image as layers, skipping files with .dockerignore.
  7. Debugging your build: how to debug failed builds, and containers that won’t start.
  8. Next steps: what to learn next.

The best way to learn from this book is to type along as you read it, running the same commands on your computer. Additionally, Chapters 2 to 7 each have a corresponding exercise to help you practice what you’ve learned.

Changelog

April 2020

  • Expanded the debugging chapter with a new section on extracting files from a failed build.
  • Clarified that --bind 0.0.0.0 and the port number used in portforwarding are specific to the server used, rather than Docker features.
  • Other small improvements.

January 2020

The original release of the book.

Ready to learn Docker packaging, quickly and effectively?

Just Enough Docker Packaging Production best practices bundle
  • Concise, focused PDF book, last updated in April 2020.
  • Exercises to solidify your understanding.
  • All updates to the 1st edition.
  • 100% money-back guarantee.
  • Everything in the book.
  • Plus, the ~40 page Python on Docker Production Checklist.
  • 35 different best practices for packaging Python applications for production, from security to reproducibility to build time.
  • Extensive examples and additional references.
  • All updates to the 1st edition.
  • 100% money-back guarantee.

Want to buy the book for your whole team? Buy a 10-person license for US$199.

Note: I prefer not to take money from teams working on projects for the military, prisons, fossil fuel extraction, surveillance, national security, or the like. If that applies to you, please don’t purchase this product.

About me

Hi, I’m Itamar Turner-Trauring.

I’ve been writing Python since 1999, and I first started using Docker in 2014, when I was part of a team that wrote one of the first distributed storage backends for Docker.

I’ve since built Telepresence, a remote development tool for Kubernetes that was adopted as a Cloud Native Computing Foundation sandbox project and has more than 2000 stars on GitHub. I’ve also deployed a number of production Python applications as Docker images.

Over the past year I’ve been researching Docker packaging for Python in production, resulting in a free guide elsewhere on this site, live training classes, a template implementing best practices, and of course this introductory book.