简体   繁体   中英

pip3 install ibm_db fails inside docker image

I'm trying to have a python serive running on a Linux Ubuntu machine. My Dockerfile has a command that successfully installs all dependecies in requirement.txt, but fails for ibm_db due to time out error. Dockerfile sample below:

FROM python:3.5

# This fails
RUN pip3 install ibm_db

# This passes without ibm_db
RUN pip3 install -r /root/bags/requirements.txt

Error printed on console:

Step 2/3 : RUN pip3 install ibm_db
 ---> Running in d0dca6b76e96
Collecting ibm_db
  Downloading https://files.pythonhosted.org/packages/98/cb/f77d9bd5f64246074af364cc30e20e3044c533890f3b67d30e89615c2fc5/ibm_db-3.0.1.tar.gz (642kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-qvht81sg/ibm-db/setup.py'"'"'; __file__='"'"'/tmp/pip-install-qvht81sg/ibm-db/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-qvht81sg/ibm-db/pip-egg-info
         cwd: /tmp/pip-install-qvht81sg/ibm-db/
    Complete output (44 lines):
    Detected 64-bit Python
    Downloading https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz
    Traceback (most recent call last):
      File "/usr/local/lib/python3.5/urllib/request.py", line 1254, in do_open
        h.request(req.get_method(), req.selector, req.data, headers)
      File "/usr/local/lib/python3.5/http/client.py", line 1107, in request
        self._send_request(method, url, body, headers)
      File "/usr/local/lib/python3.5/http/client.py", line 1152, in _send_request
        self.endheaders(body)
      File "/usr/local/lib/python3.5/http/client.py", line 1103, in endheaders
        self._send_output(message_body)
      File "/usr/local/lib/python3.5/http/client.py", line 934, in _send_output
        self.send(msg)
      File "/usr/local/lib/python3.5/http/client.py", line 877, in send
        self.connect()
      File "/usr/local/lib/python3.5/http/client.py", line 1253, in connect
        super().connect()
      File "/usr/local/lib/python3.5/http/client.py", line 849, in connect
        (self.host,self.port), self.timeout, self.source_address)
      File "/usr/local/lib/python3.5/socket.py", line 712, in create_connection
        raise err
      File "/usr/local/lib/python3.5/socket.py", line 703, in create_connection
        sock.connect(sa)
    TimeoutError: [Errno 110] Connection timed out

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-qvht81sg/ibm-db/setup.py", line 185, in <module>
        file_stream = BytesIO(request.urlopen(url, context=context).read())
      File "/usr/local/lib/python3.5/urllib/request.py", line 163, in urlopen
        return opener.open(url, data, timeout)
      File "/usr/local/lib/python3.5/urllib/request.py", line 466, in open
        response = self._open(req, data)
      File "/usr/local/lib/python3.5/urllib/request.py", line 484, in _open
        '_open', req)
      File "/usr/local/lib/python3.5/urllib/request.py", line 444, in _call_chain
        result = func(*args)
      File "/usr/local/lib/python3.5/urllib/request.py", line 1297, in https_open
        context=self._context, check_hostname=self._check_hostname)
      File "/usr/local/lib/python3.5/urllib/request.py", line 1256, in do_open
        raise URLError(err)
    urllib.error.URLError: <urlopen error [Errno 110] Connection timed out>
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
The command '/bin/sh -c pip3 install ibm_db' returned a non-zero code: 1

Tried with different docker python images 3.5, 3.5-slim, 3.6, 3.6-slim, 3.7, 3.7-slim. But error persists with all the images.

requirements.txt below:

appnope==0.1.0
attrs==19.1.0
backcall==0.1.0
bleach==3.1.0
cycler==0.10.0
decorator==4.4.0
defusedxml==0.6.0
entrypoints==0.3
ibm-db==3.0.1
ipykernel==5.1.2
ipython==7.8.0
ipython-genutils==0.2.0
ipywidgets==7.5.1
jedi==0.15.1
Jinja2==2.10.1
joblib==0.13.2
jsonschema==3.0.2
jupyter==1.0.0
jupyter-client==5.3.1
jupyter-console==6.0.0
jupyter-core==4.5.0
kiwisolver==1.1.0
MarkupSafe==1.1.1
matplotlib==3.0.3
mistune==0.8.4
nbconvert==5.6.0
nbformat==4.4.0
notebook==6.0.1
numpy==1.17.0
pandas==0.25.0
pandocfilters==1.4.2
parso==0.5.1
pexpect==4.7.0
pickleshare==0.7.5
prometheus-client==0.7.1
prompt-toolkit==2.0.9
ptyprocess==0.6.0
Pygments==2.4.2
pyparsing==2.4.2
pyrsistent==0.15.4
python-dateutil==2.8.0
pytz==2019.2
pyzmq==18.1.0
qtconsole==4.5.4
scikit-learn==0.21.3
scipy==1.3.1
seaborn==0.9.0
Send2Trash==1.5.0
six==1.12.0
terminado==0.8.2
testpath==0.4.2
toml==0.10.0
tornado==6.0.3
traitlets==4.3.2
wcwidth==0.1.7
webencodings==0.5.1
widgetsnbextension==3.5.1
grpcio==1.24.1
grpcio-tools==1.24.1

I could not recreate the issue. The build with the provided Dockerfile and requirements.txt completes successfully. That rules out an issue of your dockerfile and points to an infrastructure issue.

Second, your step pip3 install ibm_db fails. Taking a closer look at that we can see it fails to download:

https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz

can you try to curl this from your host / within the container? Are both curls successful? Do you now have the linuxx64_odbc_cli.tar.gz after executing the curl in your current folder?

curl https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz > linuxx64_odbc_cli.tar.gz

My hypothesis is that you are behind a firewall/proxy that does not allow you to download this particular file. If you can download it without any issues, we could rule out firewall/proxy as the culprit.

I suggest you to run update first:

FROM python:3.5

RUN apt-get update
RUN pip install --upgrade pip

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