Skip to content

Unable to use in docker image #204

@adolfo-ubs

Description

@adolfo-ubs

Describe the bug

Hi,

I am trying to build a docker image which uses this library

This is my Dockerfile

FROM python:3.12-slim AS runtime-image
WORKDIR /usr/src/app
ENV PYTHONUNBUFFERED=1

RUN apt-get update && \
    apt-get install -y libltdl7 && \
    rm -rf /var/lib/apt/lists/*

# Fix timezone issue
ENV TZ=Europe/Madrid
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

COPY requirements.txt ./
RUN pip install --user -r ./requirements.txt

COPY . .

CMD [ "python", "./main.py" ]

I added the line to install the libltdl7 library

but i still receive the message

  File "/root/.local/lib/python3.12/site-packages/mssql_python/db_connection.py", line 36, in connect
    conn = Connection(connection_str, autocommit=autocommit, attrs_before=attrs_before, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.12/site-packages/mssql_python/connection.py", line 89, in __init__
    self._conn = ddbc_bindings.Connection(self.connection_str, self._pooling, self._attrs_before)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Failed to load ODBC driver. If you are on Linux, please install libltdl7 package.

To reproduce

Create a basic main.py to open a connection, then use referenced Dockerfile to build an image

Additional info

Using Docker desktop on Windows 11

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationtriage doneIssues that are triaged by dev team and are in investigation.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions