Windows Docker Container finds ODBC when run on my machine but not on the server

The container runs fine on my local machine, but when running on the server the ODBC Driver does not show up in the list of servers. I should not need a DSN as I don’t have one on my local machine. has anyone run across this issue. Possibly a server setting?

Error: InterfaceError(‘IM002’, ‘[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (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"]

Output:

On my machine (both drivers found):
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

On Server (Only SQL Server default driver found):
2023-12-20 14:09:36.276160  Installed Driver #1 ...SQL Server

Are you sure you are using the same version of the image and not overriding the folder of the drivers (I have no idea where drivers are) by mounting a host folder over it?

Hi, Thanks for the reply, I believe I am using the same image, not sure what I do use the -v flag when running to create a volume. Is that what you mean by a host folder? It does run fine on my PC but just not on the server.

There are volumes and bind mounts. I meant bind mounts

Try the container without any mount on the server and check the filesystem that way simply using docker exec .
to start a shell in the running container or pass powershell or cmd.exe to docker run so you can find out what is in the container. I don’t know what the difference is and for me, it would be hard to guess if not overriding the driver folder. If it is something Windows specific, I won’t be able to tell, as I don’t run Windows containers

I ran it without a mount, when I do exec, it says the container is not running.

As a follow up, we used a work-around by creating an image on a local Windows 10 PC using Docker Save and then doing a docker load on the server. The dockerfile then references the loaded image on the server using the “From” statement.