Search code examples
dockermariadbpyodbcalpine-linux

How to install MariaDB ODBC drivers in Docker/Alpine


I see that Alpine supports in its Docker container a MariaDB ODBC Driver as listed here. I need to install it to be used with pyodbc.

What is the Dockerfile command that installs the driver in the image?

Something along the lines of RUN apk add mariadb-connector-odbc ?


Solution

  • My clean install of Alpine had an /etc/apk/repositories file that looked like

    #/media/cdrom/apks
    http://mirror.reenigne.net/alpine/v3.13/main
    #http://mirror.reenigne.net/alpine/v3.13/community
    #http://mirror.reenigne.net/alpine/edge/main
    #http://mirror.reenigne.net/alpine/edge/community
    #http://mirror.reenigne.net/alpine/edge/testing
    

    With that setup

    apk add mariadb-connector-odbc
    

    failed. However, after uncommenting the last line …

    #/media/cdrom/apks
    http://mirror.reenigne.net/alpine/v3.13/main
    #http://mirror.reenigne.net/alpine/v3.13/community
    #http://mirror.reenigne.net/alpine/edge/main
    #http://mirror.reenigne.net/alpine/edge/community
    http://mirror.reenigne.net/alpine/edge/testing
    

    … the same command succeeded

    localhost:~# apk add mariadb-connector-odbc
    fetch http://mirror.reenigne.net/alpine/edge/testing/x86_64/APKINDEX.tar.gz
    (1/3) Installing readline (8.1.0-r0)
    (2/3) Installing unixodbc (2.3.9-r1)
    (3/3) Installing mariadb-connector-odbc (3.1.11-r0)
    Executing busybox-1/32/1-r6.trigger
    OK: 903 MiB in 146 packages
    localhost:~# ls -la /usr/lib/mariadb
    total 536
    drwxr-xr-x    2 root     root         4096 May 14 22:43 .
    drwxr-xr-x    6 root     root         4096 May 14 22:43 ..
    -rwxr-xr-x    1 root     root       537856 Jan  6 02:39 libmaodbc.so