I’m encountering a problem when building a Docker image using a Python-based Dockerfile. I’m trying to use the mysqlclient library (version 2.2.0) and Django (version 4.2.2). Here is my Dockerfile:
FROM python:3.11-alpine
WORKDIR /usr/src/app
COPY requirements.txt .
RUN apk add --no-cache gcc musl-dev mariadb-connector-c-dev &&
pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
The problem arises when the Docker build process reaches the point of installing the mysqlclient package. I get the following error: Exception: Can not find valid pkg-config name
To address this issue, I tried adding pkgconfig to the apk add command, Unfortunately, this didn’t help and the same error persists.
I would appreciate any guidance on how to resolve this issue.
Thank you in advance.
2
Answers
Have you tried updating before adding pkgconfig ? I’ve tried and it work perfectly.
mysqlclient 2.2.0 added a dependency on pkg-config, which might not exist as such on alpine. See https://github.com/PyMySQL/mysqlclient/issues/620
You might have luck pinning to a prior version of mysqlclient