python Windows Docker容器在我的机器上运行而不是在服务器上运行时会找到ODBC

vlju58qv  于 2024-01-05  发布在  Python
关注(0)|答案(1)|浏览(132)

容器在我的本地机器上运行正常,但在服务器上运行时,ODBC驱动程序未显示在服务器列表中。我不需要DSN,因为我的本地机器上没有DSN。有人遇到过这个问题吗?可能是服务器设置?
错误:InterfaceError('IM002','[IM002] [Microsoft][ODBC Driver Manager]未找到数据源名称,未指定默认驱动程序(0)(SQLDriverConnect错误')
Dockerfile:

  1. FROM python:3.10.10-windowsservercore-1809 as base
  2. WORKDIR "C:\src"
  3. COPY vc_redist.x64.exe c:/
  4. COPY msodbcsql_18.3.2.1.msi c:/
  5. RUN c:\\vc_redist.x64.exe /install /passive /norestart
  6. RUN MSIEXEC /UNREGISTER
  7. RUN MSIEXEC /REGSERVER
  8. RUN msiexec.exe /i C:\\msodbcsql_18.3.2.1.msi /norestart /qn /quiet
  9. /passive IACCEPTMSODBCSQLLICENSETERMS=YES
  10. #RUN apt-get install -y C:\\msodbcsql_18.3.2.1.msi
  11. #RUN msiexec /quiet /passive /qn /i msodbcsql.msi
  12. IACCEPTMSODBCSQLLICENSETERMS=YES ADDLOCAL=ALL
  13. #RUN Start-Process 'c:/msodbcsql_18.3.2.1.msi' '/qn /norestart /L*V "odbc.log"' -PassThru | Wait-Process;
  14. RUN pip install "poetry==1.4.0"
  15. COPY my.lock .
  16. COPY my.toml .
  17. RUN poetry config virtualenvs.create true
  18. RUN poetry install --no-interaction --no-ansi
  19. COPY ["myPgm.py", "."]
  20. COPY ["myJsonFile.json", "."]
  21. CMD ["poetry","run",
  22. "python","myPgm.py","Param1","Param2","Param3","Param4","Parm5"]

字符串
在我的机器上本地运行容器,它工作正常。当在服务器上运行时,它找不到ODBC驱动程序。它只找到本机SQL Server驱动程序。
在我的机器上(两个驱动程序都找到):

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


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

  1. 2023-12-20 14:09:36.276160 Installed Driver #1 ...SQL Server

guykilcj

guykilcj1#

作为后续,我们使用了一种变通方法,即使用Docker保存在本地Windows 10 PC上创建一个镜像,然后在服务器上执行Docker加载。然后,dockerfile使用“From”语句引用服务器上加载的镜像。

相关问题