Python 3.7 Docker images

Question:

I want to dockerize my python app. I went to Docker hub and discovered that there are a variety of likely-sounding base images.

3.7.0-stretch, 3.7-stretch, 3-stretch, stretch (3.7/stretch/Dockerfile)
3.7.0-slim-stretch, 3.7-slim-stretch, 3-slim-stretch, slim-stretch, 3.7.0-slim, 3.7-slim, 3-slim, slim (3.7/stretch/slim/Dockerfile)
3.7.0-alpine3.8, 3.7-alpine3.8, 3-alpine3.8, alpine3.8, 3.7.0-alpine, 3.7-alpine, 3-alpine, alpine (3.7/alpine3.8/Dockerfile)
3.7.0-alpine3.7, 3.7-alpine3.7, 3-alpine3.7, alpine3.7 (3.7/alpine3.7/Dockerfile)

Despite my attempts at a Google search, I couldn’t figure out the differeces between “stretch”, “slim”, “slim-stretch”, and alpine. Help?

Asked By: David Goldfarb

||

Answers:

The Github repo with Dockerfiles is here, but it’s very dynamic and not easily readable:

https://github.com/docker-library/python

The readme is also located here:

https://github.com/docker-library/docs/tree/master/python

Looks like info about stretch is really missing. Could not find even in git revision history if it was accidentally removed.

I have created an issue: https://github.com/docker-library/python/issues/343

Stretch is a codename for Debian 9 – currently the stable version (until 2019-07-06, when Debian 10 Buster was released). The “oldstable” Debian 8 has codename Jessie.

https://wiki.debian.org/DebianReleases

My personal recommendation is to use the minimalistic Alpine images and fallback to the Debian ones if something doesn’t work 🙂

Comparison of Debian vs. Alpine (from the Docker point of view if possible):

From my limited experience the most notable difference is apt vs. apk and GNU libc6 vs. musl libc. And Alpine uses busybox instead of the full versions of many system commands.

Update: Many Python wheels with compiled binary code will work with Debian-based images, but have to be recompiled (by pip install) for Alpine-based images. In these cases I recommend to use the Debian-based images.

Answered By: Messa

Please notice that at the bottom of the Python Oficial Docker Hub you’ll get good clues about whats in the repo.

Stretch, Apline, Buster are referring to the base OS the container uses.

Stretch and Buster are consecutive versions of Debian, while Alpine is a minimalistic version for Linux based on musl and BusyBox.

The difference in size is considerable, going up to 30x from Alpine to others, but trade-offs are to be taken in account as a better-community to better-size-performance kind.

Also, take in account what your container will need to have installed and how minimalistic it can get.

Answered By: RicarHincapie
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.