As in the title: I have troubles switching to MariaDB when I use Docker.
As long as I launched many different databases locally from my disk (default SQLite, PostgreSQL and MariaDB), every configuration worked fine. SQLite and PostgreSQL work with Docker as well (installation of Postgres' driver goes smoothly), but MariaDB reports issues with fetching MariaDB Connector/C.
Dockerfile:
FROM python:3.8.5-alpine3.12
ENV PYTHONUNBUFFERED 1
COPY ./requirements.txt /requirements.txt
RUN apk add libmariadb3
RUN pip install -r /requirements.txt
RUN mkdir /app
WORKDIR /app
COPY ./app /app
RUN adduser --disabled-password user
USER user
docker-compose.yml:
version: "3"
services:
app:
build:
context: .
ports:
- "8000:8000"
volumes:
- ./app:/app
command:
sh -c "python manage.py runserver 0.0.0.0:8000"
environment:
[...]
depends_on:
- db
db:
image: mariadb:10.5.4
environment:
[...]
The error I'm getting is:
[...]
Step 4/11 : RUN apk add libmariadb3
---> Running in 5a3e568b8ac3
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
libmariadb3 (missing):
required by: world[libmariadb3]
ERROR: Service 'app' failed to build: The command '/bin/sh -c apk add libmariadb3' returned a non-zero code: 1
According to documentation, MariaDB Connector/C can be installed with apt-get, yum, dnf, zypper, or from source, but apparently not with apk.
Considered solutions:
- Download
MariaDB Connector/Ctar.gz to the project directory and copy it while building image. Cons: one has to take care of updating the driver manually. - Use a Python image run on Ubuntu. Cons: is it small enough? Is it still supported (not visible on the list in Docker's Hub)?
As I wrote above, these solutions don't seem to be satisfactory. Do you know other ways to configure MariaDB to work with Python?