Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install ODBC Driver 17 in a docker image based on windows server core?

I'm setting up a new docker windows servercore image for my application. Data access uses ODBC Driver 17 for SQL Server. I need to install this on the image so in my Dockerfile I included the following:

FROM mcr.microsoft.com/windows/servercore:ltsc2016

COPY msodbcsql_17.3.1.1_x64.msi c:\\msodbcsql_17.3.1.1_x64.msi

RUN msiexec.exe /i C:\\msodbcsql_17.3.1.1_x64.msi /norestart /qn IACCEPTMSODBCSQLLICENSETERMS=YES
...

When I run docker build... I get the following error

The command 'cmd /S /C msiexec.exe /i C:\\msodbcsql_17.3.1.1_x64.msi /norestart /qn IACCEPTMSODBCSQLLICENSETERMS=YES' returned a non-zero code: 1603

Code 1603 indicates that a restart is required.

I'm not sure how an image can be restarted. How do I proceed ahead with this? Without the driver, I won't be able to get my application running.

like image 915
SAK Avatar asked Jul 16 '19 06:07

SAK


People also ask

How do I manually install ODBC drivers?

1 Installing the Windows Connector/ODBC Driver Using the Zipped DLL Package. If you have downloaded the zipped DLL package: Unzip the installation files to the location you want it installed. Run the included batch file to perform an installation from the current directory and registers the ODBC driver.

What is the ODBC driver 17 for SQL Server?

The Microsoft ODBC Driver 17 for SQL Server provides native connectivity from Windows, Linux, & macOS to SQL Server and Azure SQL Databases. Note that this driver supports SQL Server 2019 only from version 17.3. More info about this driver can be found at the Microsoft product page.


1 Answers

So I ran the MSI manually in the container with logging enabled. It turns out that the failure was occurring due to missing VC++ redistributable.

So, I updated the Dockerfile by adding a line to copy and install vc_redist.x64.exe which fixed the issue for me.

Snippet from the Dockerfile that solved the problem for me.

FROM mcr.microsoft.com/dotnet/framework/aspnet:4.7.2
COPY vc_redist.x64.exe c:/ \
     msodbcsql_17.3.1.1_x64.msi c:/
RUN c:\\vc_redist.x64.exe /install /passive /norestart 
RUN msiexec.exe /i C:\\msodbcsql_17.3.1.1_x64.msi /norestart /qn /quiet /passive IACCEPTMSODBCSQLLICENSETERMS=YES 

...

Just posting this answer here in case someone else stumbles upon the same issue.

like image 110
SAK Avatar answered Oct 23 '22 00:10

SAK