Search code examples
pythondockermariadb

Mariadb in Docker: MariaDB Connector/Python requires MariaDB Connector/C >= 3.2.4, found version 3.1.16


I try the following Dockerfile:

# syntax=docker/dockerfile:1
FROM python:3.11-slim-bullseye
EXPOSE 80
WORKDIR /app
RUN apt-get update && apt-get install -y
RUN apt install gcc libmariadb3 libmariadb-dev libmariadb-dev-compat -y
RUN pip install --upgrade pip
RUN pip install Flask Flask-SQLAlchemy flask-marshmallow marshmallow-sqlalchemy
RUN pip install mariadb==1.0.0
COPY ./back .
CMD [ "python3", "app.py"]

I get this error: MariaDB Connector/Python requires MariaDB Connector/C >= 3.2.4, found version 3.1.16

And when I try with mariadb==1.0.0 I get this error: MariaDB Connector/Python requires MariaDB Connector/C >= 3.1.3, found version 3.1.16

I see the answer to this post Installing MariaDB in Dockercontainer - requires MariaDB Connector/C >= 3.2.4, found version 3.1.16 but doesn't work


Solution

  • Pulling the latest MariaDB Connector/C from MariaDB managed to install with the latests python mariadb:

    FROM python:3.11-slim-bullseye
    EXPOSE 80
    WORKDIR /app
    RUN apt-get update && apt-get install -y gcc wget
    RUN wget https://dlm.mariadb.com/2678574/Connectors/c/connector-c-3.3.3/mariadb-connector-c-3.3.3-debian-bullseye-amd64.tar.gz -O - | tar -zxf - --strip-components=1 -C /usr
    RUN pip install --upgrade pip
    RUN pip install Flask Flask-SQLAlchemy flask-marshmallow marshmallow-sqlalchemy
    RUN pip install mariadb
    

    The libmariadb-dev packaged by Debian bulleye was too old.

    libmariadb3 are client plugins, I'm not sure if you need those.