简体   繁体   English

pip3 install ibm_db 在 docker 映像中失败

[英]pip3 install ibm_db fails inside docker image

I'm trying to have a python serive running on a Linux Ubuntu machine.我正在尝试在 Linux Ubuntu 机器上运行 python 服务。 My Dockerfile has a command that successfully installs all dependecies in requirement.txt, but fails for ibm_db due to time out error.我的 Dockerfile 有一个命令可以成功安装 require.txt 中的所有依赖项,但由于超时错误导致 ibm_db 失败。 Dockerfile sample below: Dockerfile 样品如下:

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.尝试使用不同的 docker python 图像 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: requirements.txt 下面:

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.使用提供的 Dockerfile 和 requirements.txt 构建成功完成。 That rules out an issue of your dockerfile and points to an infrastructure issue.这排除了您的 dockerfile 的问题,并指出了基础设施问题。

Second, your step pip3 install ibm_db fails.其次,您的步骤pip3 install ibm_db失败。 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 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?你能从你的主机/容器内尝试 curl 这个吗? Are both curls successful?两个卷发都成功了吗? Do you now have the linuxx64_odbc_cli.tar.gz after executing the curl in your current folder?在当前文件夹中执行 curl 后,您现在是否拥有 linuxx64_odbc_cli.tar.gz?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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