when I want to build my Alpine Docker I get an error when I define specific python version.
My Dockerfile:
FROM python:3-alpine
RUN apk --no-cache add build-base openldap-dev python2-dev 'python3=3.6.9-r3' 'python3-dev=3.6.9-r3'
RUN pip3 install python-ldap sqlalchemy requests
ADD ucs-root-ca.crt /usr/local/share/ca-certificates/foo.crt
RUN chmod 644 /usr/local/share/ca-certificates/foo.crt && update-ca-certificates
COPY templates ./templates
COPY api.py filedb.py syncer.py ./
VOLUME [ "/db" ]
VOLUME [ "/conf/dovecot" ]
VOLUME [ "/conf/sogo" ]
ENTRYPOINT [ "python3", "syncer.py" ]
I get the following Error when I want to build my dockerfile:
ERROR: unable to select packages:
python3-3.8.7-r0:
breaks: world[python3=3.6.9-r3]
satisfies: python3-dev-3.8.7-r0[python3=3.8.7-r0]
python3-dev-3.8.7-r0:
breaks: world[python3-dev=3.6.9-r3]
The command '/bin/sh -c apk --no-cache add build-base openldap-dev python2-dev 'python3=3.6.9-r3' 'python3-dev=3.6.9-r3'' returned a non-zero code: 2
The error from apk is since that specific Python 3 version is not found in the Alpine repositories.
python3=3.6.9-r3 currently only lives in the Alpine 3.9 main repository:
https://pkgs.alpinelinux.org/package/v3.9/main/x86/python3
The python:3-alpine image seems to be based on Alpine 3.13, the latest. Therefore, the package for 3.6.9 is not to be found.
For installing that specific version, you have to tell apk to use that 3.9 repository (if you're not on Alpine 3.9):
apk add python3-dev=3.6.9-r3 --repository=http://dl-cdn.alpinelinux.org/alpine/v3.9/main
However, there's a catch: python3-dev=3.6.9-r3 is compatible with Alpine 3.9, and will not mix well with later Alpine versions. For example:
gdbm-1.19-r0:
conflicts: gdbm-1.13-r1
gdbm-1.13-r1[so:libgdbm_compat.so.4=4.0.0]
satisfies: python3-3.6.9-r3[so:libgdbm_compat.so.4]
libsasl-2.1.27-r10[so:libgdbm.so.6]
python2-2.7.18-r1[so:libgdbm_compat.so.4]
Therefore, if you're inclined to use Python 3.6.9 specifically, you'll have to run it on Alpine 3.9, which is quite old.
If you don't mind using an older Alpine version, simply replace the first line in your Dockerfile to:
FROM alpine:3.9
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