
Small images: All things being equal, it’s better to have a smaller Docker image than a bigger Docker image. Up-to-date Python: While this can be worked around by installing Python yourself, having an up-to-date Python available saves you some effort. Extensive dependencies: For some applications less popular dependencies may be required-a base image with access to a large number of libraries makes this easier. Up-to-date dependencies: Unless you’re building a very simple application, you will likely depend on operating system-installed libraries and applications (e.g. Security updates: You want the base image to be well-maintained, so that you get security updates for the base operating system in a timely manner. Stability: You want a build today to give you the same basic set of libraries, directory structure, and infrastructure as a build tomorrow, otherwise your application will randomly break. There are a number of common criteria for choosing a base image, though your particular situation might emphasize, add, or remove some of these: Need to ship quickly, and don’t have time to figure out every detail on your own? Read the concise, action-oriented Python on Docker Production Handbook.
Note: Outside any specific best practice being demonstrated, the Dockerfiles in this article are not examples of best practices, since the added complexity would obscure the main point of the article.
Python 3.6.4 for debian 9 series#
Docker has a series of “official” Docker base images based on various Linux distributions, and also base images that package specific programming languages, in particular Python.