Marco Bravo

Logo

Marco Bravo's DEV Profile If you don’t know, ask – if you know, share! ~ opensource mindset Baseball ball image


➠ "We may not have control over our circumstances, but we do have control over our minds"
➠ What do I want to do next?
Cloud and rainbow image

View My GitHub Profile

29 January 2020

The best Docker base image for Python

by Marco Bravo

Docker Python image

When you’re building a Docker image for your Python application, you’re building on top of an existing image—and there are many possible choices. There are OS images like Ubuntu and CentOS, and there are the many different variants of the python base image.

Which one should you use? Which one is better? There are many choices, and it may not be obvious which is the best for your situation.

Related article Why you shouldn’t use Alpine Linux explains why Alpine makes Python Docker builds 50× slower, and images 2× larger.

So what should you use?

As of January 2020, Debian 10 (“Buster”) is a good operating system base:

  1. It’s more up-to-date than ubuntu:18.04.
  2. It’s stable, and won’t have significant library changes.
  3. There’s less chances of weird production bugs than Alpine.

And the official Python Docker images based off of Debian Buster also give you the full range of Python releases.

The official Docker Python image in its slim variant—e.g. python:3.8-slim-buster—is a good base image for most use cases. it’s 60MB when downloaded, 180MB when uncompressed to disk, it gives you the latest Python releases, and it’s got all the benefits of Debian Buster.

Full article

tags: docker - image - python - tips - ubuntu - centos - debian