0

I have implemented a .Net webapi application which pulls the data from databricks Applications . I have installed SIMBA ODBC drivers in my local and was able to connect to databricks cluster from my local .net application.

Now I want to run & locally test the webapi application with DOCKER as run mode. So how do I install SIMBA ODBC drivers inside the container?

Tried out below 'Dockerfile', got below exception

Unexpected error occurred - Dependency unixODBC with minimum version 2.3.1 is required.\nUnable to load shared library 'libodbc.so.2' or one of its dependencies

FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
COPY ["NuGet.Config", "."]
COPY ["src/myApi/myApi.csproj", "src/myApi/"]
COPY ["src/myApi.Models/myApi.Models.csproj", "src/myApi.Models/"]
RUN dotnet restore "src/myApi/myApi.csproj"
COPY . .
WORKDIR "/src/src/myApi"
RUN dotnet build "myApi.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "myApi.csproj" -c Release -o /app/publish /p:UseAppHost=false
   
  
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .

# Install Databricks ODBC driver.
RUN apt update && apt install -y unixodbc unixodbc-dev freetds-dev sqsh tdsodbc unzip libsasl2-modules-gssapi-mit
RUN curl -sL https://databricks.com/wp-content/uploads/drivers-2020/SimbaSparkODBC-2.6.16.1019-Debian-64bit.zip -o databricksOdbc.zip && unzip databricksOdbc.zip
RUN dpkg -i SimbaSparkODBC-2.6.16.1019-Debian-64bit/simbaspark_2.6.16.1019-2_amd64.deb

ENTRYPOINT ["dotnet", "myApi.dll"]
191180rk
  • 735
  • 2
  • 12
  • 37

1 Answers1

0

The most probable cause is that you're using mcr.microsoft.com/dotnet/aspnet of version 3.1 that was released very long time ago and not supported anymore. The base version should be based on the Debian 10 that included UnixODBC 2.3.0 or lower. Right now it should be 2.3.6 (see here), so doing apt-get update could help to bring dependencies to the latest level.

But real solution is to use new Docker images with newer ASP.Net versions as you're running on potentially vulnerable platform (see more here). You also need to use newer versions of Databricks ODBC driver - that's very old.

Alex Ott
  • 80,552
  • 8
  • 87
  • 132