简体   繁体   中英

How to install ibm_db_dbi module in python3.6 docker image?

I have successfully installed ibm_db v3.0.1 package in docker image but when i am trying to import ibm_db_dbi module it throw the error.

Dockerfile :

FROM python:3.6.8-alpine3.9

WORKDIR /run

COPY . /run

RUN pip install --trusted-host pypi.python.org -r requirements.txt

EXPOSE 7000

CMD ["python", "run.py"]

after build its successfully executed the below ibm_db module to image.

Downloading https://files.pythonhosted.org/packages/98/cb/f77d9bd5f64246074af364cc30e20e3044c533890f3b67d30e89615c2fc5/ibm_db-3.0.1.tar.gz (642kB)

Please help me resolve this issue.

command to run docker image :-  docker run -it -p 7000:7000  dotsapi

error while running the docker file:-

File "/run/Informix_Conn.py", line 3, in

 import ibm_db_dbi as db ImportError: Error loading shared library libcrypt.so.1: No such file or directory (needed by 

/usr/local/lib/python3.6/site-packages/clidriver/lib/libdb2.so.1)

Thanks in advance!!

You can add a pip install ibm_db in your dockerfile or create a requirements.txt file. And call him in your dockerfile with :

 ADD        ./requirements.txt ./
 RUN        python3 -m pip install -r requirements.txt

EDIT It worked for me : In my dockerfile :

FROM       python:3.6
ADD        ./requirements.txt ./
RUN        python3 -m pip install -r requirements.txt
ADD        ./test.py /run

After building succesfully I ran my image with

docker run --name testpython testpython:1 sleep 3600

Go in my container

docker exec -it testpython /bin/bash

And when I run a python console or my test script, the import is OK.

NOTE : With the image python:3.6.8-alpine3.9 the build doesn't work. Check this to see why

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM