ODBC Drivers - Docker

I have tried just about anything in terms of installing the ODBC drivers for connecting to an Azure SQL server. Right now i am installing R using a docker image, however i can't get the drivers to get installed. Been using the following:

FROM rocker/tidyverse
MAINTAINER @me

RUN apt-get update && apt-get install -y \
    unixodbc \
    unixodbc-dev \
    tdsodbc \
    odbc-postgresql \
    libsqliteodbc \
    ## clean up
    && apt-get clean \ 
    && rm -rf /var/lib/apt/lists/ \ 
    && rm -rf /tmp/downloaded_packages/ /tmp/*.rds```

Any ideas to how I can install them?

I think you may need to install the specific driver for SQL server and not just unixodbc
layer
This doc may help
https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017

Before you install tdsodbc run this:

# Ensure FreeTDS is added to unixodbc upon installation
RUN echo tdsodbc freetds/addtoodbc boolean true | debconf-set-selections

Otherwise the driver will not be automatically added to the list of available drivers without subsequently editing /etc/odbcinst.ini to add:

[FreeTDS]
Description=TDS driver (Sybase/MS SQL)
Driver=libtdsodbc.so
Setup=libtdsS.so
CPTimeout=
CPReuse=
UsageCount=1
1 Like

Thanks for the help guys =)

This dockerfile actually helped me fix everything:

# install cron and R package dependencies
RUN apt-get update && apt-get install -y \
    cron \
    nano \
    tdsodbc \
    odbc-postgresql \
    libsqliteodbc \
    ## clean up
    && apt-get clean \ 
    && rm -rf /var/lib/apt/lists/ \ 
    && rm -rf /tmp/downloaded_packages/ /tmp/*.rds

RUN apt-get update \
 && apt-get install --yes --no-install-recommends \
        apt-transport-https \
        curl \
        gnupg \
        unixodbc-dev \
 && curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
 && curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list \
 && apt-get update \
 && ACCEPT_EULA=Y apt-get install --yes --no-install-recommends msodbcsql17 \
 && install2.r odbc \
 && apt-get clean \
 && rm -rf /var/lib/apt/lists/* \
 && rm -rf /tmp/*```
3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.