4

I'm trying to connect my .net core application, hosted on a unix docker container to an external Vertica database.

It works fine when it's a windows client because there are Vertica Drivers for Windows. But there isn't a unix driver for Vertica under unix.

When I try to run a Query against Vertica I get the following error:

Dependency unixODBC with minimum version 2.3.1 is required. Unable to load shared library 'libodbc.so.2' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibodbc.so.2.so:

My docker file looks like this

FROM microsoft/dotnet:sdk AS build-env
WORKDIR /app
ARG DEBIAN_FRONTEND=noninteractive

# Copy csproj and restore as distinct layers
COPY ./*.sln ./
COPY ./MyApp/*.csproj ./MyApp/
RUN dotnet restore MyApp.sln
COPY . ./
RUN dotnet publish MyApp.sln -c Release  -f=netcoreapp2.1 -o out 
RUN cp /app/MyApp/*.yml /app/MyApp/out
RUN cp /app/*.ini /app/VMyApp/out
#ODBC 
FROM microsoft/dotnet:aspnetcore-runtime
RUN apt-get update
RUN apt-get install -y apt-utils
RUN curl -O -k https://www.vertica.com/client_drivers/9.1.x/9.1.1-0/vertica-client-9.1.1-0.x86_64.tar.gz
RUN tar vzxf vertica-client-9.1.1-0.x86_64.tar.gz && rm vertica-client-9.1.1-0.x86_64.tar.gz
RUN apt-get install -y unixodbc-dev
ADD odbc.ini /root/odbc.ini
ADD odbcinst.ini /root/odbcinst.ini
ADD vertica.ini /root/vertica.ini


ENV  VERTICAINI=/root/vertica.ini 
ENV ODBCINI=/root/odbc.ini
RUN echo "$VERTICAINI $ODBCINI"
WORKDIR /app
COPY --from=build-env /app/MyApp/out .
ENTRYPOINT ["dotnet", "MyApp.dll"]
Brian
  • 1,845
  • 1
  • 22
  • 37
  • by installing apt-name: apt-get install apt-name && apt-name update; then running apt-name search "libodbc.so.2" it returns libodbc1: /usr/lib/x86_64-linux-gnu/libodbc.so.2 So if you install libodbc1: apt-get install libodbc1 you should have the file available in /usr/lib/x86_64-linux-gnu/libodbc.so.2 – Miguel Marques Dec 03 '19 at 22:23
  • apt-file not apt-name – Miguel Marques Dec 03 '19 at 22:46

0 Answers0