If I build the simpliest docker image based on Alpine that includes Python:
FROM python:3.7-alpine3.9
I can successfully enter it and verify that the installed version is 3.7:
/ # python --version
Python 3.7.3
/ # python3 --version
Python 3.7.3
However if I install some packages that require Python3, for examplepython3-dev (that is required by other packages) or Python3 itself, Alpine does not use version 3.7 but uses 3.6 for some reason that I don't understand:
/ # apk add python3-dev
(1/3) Installing pkgconf (1.6.0-r0)
(2/3) Installing python3 (3.6.8-r2)
(3/3) Installing python3-dev (3.6.8-r2)
Executing busybox-1.29.3-r10.trigger
OK: 108 MiB in 38 packages
printenv also shows that (during the docker image build) version 3.7.x is used but package system does not reflect this. Excerpt:
PYTHON_VERSION=3.7.3
I see here there's Python 3.6 as a default version for all Alpine versions up to 3.9. Python 3.7 is available for the "edge" only.
I also found answer to this which doesn't work either:
# apk add python3 --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main
(1/1) Installing python3 (3.6.8-r2)
Python 3.6 is installed. However if I use the simpliest Alpine without Python FROM alpine:3.9 and use the same command, Python 3.7 is installed:
# apk add python3 --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main
<TRIMMED_TEXT>
(11/11) Installing python3 (3.7.3-r0)
How can I tell the package manager in python:3.7-alpine3.9 to use Python 3.7 instead of Python 3.6?
If you remove the (virtual) .python-rundeps package beforehand, the installation will work as you intend it.
FROM python:3.7-alpine3.9
RUN \
apk update \
&& apk del .python-rundeps \
&& apk add --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main \
python3-dev=3.7.3-r0
Building this image results in:
...
(12/13) Installing python3 (3.7.3-r0)
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With