Python 3.7 Docker images

2020-05-21 09:00发布

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?

标签: python docker
1条回答
Fickle 薄情
2楼-- · 2020-05-21 09:48

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 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 recoomend to use the Debian-based images.

查看更多
登录 后发表回答