如何在基于windows server core的docker镜像中安装ODBC Driver 17?

问题描述 投票:0回答:2

我正在为我的应用程序设置一个新的 docker windows servercore 映像。数据访问使用ODBC Driver 17 for SQL Server。我需要将其安装在图像上,因此在我的

Dockerfile
中我包含了以下内容:

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
...

当我运行

docker build...
时,我收到以下错误

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

代码

1603
表示需要重启。

我不确定如何重新启动图像。我该如何继续?如果没有驱动程序,我将无法运行我的应用程序。

docker dockerfile docker-for-windows
2个回答
14
投票

因此,我在启用日志记录的容器中手动运行 MSI。事实证明,失败是由于缺少 VC++ 可再发行组件而发生的。

因此,我通过添加一行来复制和安装

Dockerfile
 来更新 
vc_redist.x64.exe
,这为我解决了问题。

来自

Dockerfile
的片段为我解决了问题。

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 

...

只是在这里发布这个答案,以防其他人偶然发现同样的问题。


0
投票

我知道这是一个旧线程。我将上述方法与下面的 Dockerfile 结合使用。该容器在我的本地计算机上运行良好,但在服务器上运行时,ODBC 驱动程序不会显示在服务器列表中。我还直接在服务器上安装了驱动程序。我不需要 DSN,因为我的本地计算机上没有 DSN。有没有人遇到过这个问题。可能是服务器设置?

错误: InterfaceError('IM002', '[IM002] [Microsoft][ODBC 驱动程序管理器] 未找到数据源名称且未指定默认驱动程序 (0) (SQLDriverConnect)')

Docker 文件: 来自 python:3.10.10-windowsservercore-1809 作为基础 工作目录“C:\src”

COPY vc_redist.x64.exe c:/
COPY msodbcsql_18.3.2.1.msi c:/

RUN c:\\vc_redist.x64.exe /install /passive /norestart 

RUN MSIEXEC /UNREGISTER
RUN MSIEXEC /REGSERVER

RUN msiexec.exe /i C:\\msodbcsql_18.3.2.1.msi /norestart /qn /quiet 
/passive IACCEPTMSODBCSQLLICENSETERMS=YES 
#RUN apt-get install -y C:\\msodbcsql_18.3.2.1.msi
#RUN msiexec /quiet /passive /qn /i msodbcsql.msi 
IACCEPTMSODBCSQLLICENSETERMS=YES ADDLOCAL=ALL 
#RUN  Start-Process   'c:/msodbcsql_18.3.2.1.msi' '/qn /norestart /L*V 
"odbc.log"' -PassThru | Wait-Process;

RUN pip install "poetry==1.4.0"

COPY my.lock .
COPY my.toml .

RUN poetry config virtualenvs.create true
RUN poetry install --no-interaction --no-ansi

COPY ["myPgm.py", "."]
COPY ["Config.json", "."]
CMD ["poetry","run", "python", 
"myPgm.py","Param1","Param2","Param3","Param4","Parm5"]
© www.soinside.com 2019 - 2024. All rights reserved.