Windows Docker 容器在我的计算机上运行时找到 ODBC,但在服务器上找不到

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

容器在我的本地计算机上运行良好,但在服务器上运行时,ODBC 驱动程序不会显示在服务器列表中。我不需要 DSN,因为我的本地计算机上没有 DSN。有人遇到过这个问题吗?可能是服务器设置?

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

Dockerfile:

    FROM python:3.10.10-windowsservercore-1809 as base 
    WORKDIR "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 ["myJsonFile.json", "."]

    CMD ["poetry","run", 
    "python","myPgm.py","Param1","Param2","Param3","Param4","Parm5"]

在我的机器上本地运行容器,它运行良好。当在服务器上运行时 未找到 ODBC 驱动程序。它只找到本机 SQL Server 驱动程序。

在我的机器上(两个驱动程序均已找到):

2023-12-20 14:49:49.511504  Installed Driver #1 ... SQL Server
2023-12-20 14:49:49.511504  Installed Driver #2 ... ODBC Driver 18 for SQL Server

在服务器上(仅找到 SQL Server 默认驱动程序):

2023-12-20 14:09:36.276160  Installed Driver #1 ...SQL Server
python windows docker odbc driver
1个回答
0
投票

作为后续措施,我们使用了一种解决方法,即使用 Docker Save 在本地 Windows 10 PC 上创建映像,然后在服务器上执行 docker load。然后 dockerfile 使用“From”语句引用服务器上加载的图像。

© www.soinside.com 2019 - 2024. All rights reserved.