6

I'm running docker in docker instance on which I'm trying to build docker image. However during the build everything hangs on pipe install command. My base image is nvidia/cuda:10.1-base-ubuntu16.04.

Here is command I'm trying to run in my Dockerfile

  python -m pip --no-cache-dir --default-timeout=1000 install -U jupyter \
  jupyter_contrib_nbextensions \
  jupytext -vvv &&\

Here are detailed logs

Collecting jupyter
  1 location(s) to search for versions of jupyter:
  * https://pypi.org/simple/jupyter/
  Getting page https://pypi.org/simple/jupyter/
  Found index url https://pypi.org/simple
  Starting new HTTPS connection (1): pypi.org:443
  https://pypi.org:443 "GET /simple/jupyter/ HTTP/1.1" 200 496
  Analyzing links from page https://pypi.org/simple/jupyter/
    Found link https://files.pythonhosted.org/packages/83/df/0f5dd132200728a86190397e1ea87cd76244e42d39ec5e88efd25b2abd7e/jupyter-1.0.0-py2.py3-none-any.whl#sha256=5b290f93b98ffbc21c0c7e749f054b3267782166d72fa5e3ed1ed4eaf34a2b78 (from https://pypi.org/simple/jupyter/), version: 1.0.0
    Found link https://files.pythonhosted.org/packages/c9/a9/371d0b8fe37dd231cf4b2cff0a9f0f25e98f3a73c3771742444be27f2944/jupyter-1.0.0.tar.gz#sha256=d9dc4b3318f310e34c82951ea5d6683f67bed7def4b259fafbfe4f1beb1d8e5f (from https://pypi.org/simple/jupyter/), version: 1.0.0
    Found link https://files.pythonhosted.org/packages/fc/21/a372b73e3a498b41b92ed915ada7de2ad5e16631546329c03e484c3bf4e9/jupyter-1.0.0.zip#sha256=3e1f86076bbb7c8c207829390305a2b1fe836d471ed54be66a3b8c41e7f46cc7 (from https://pypi.org/simple/jupyter/), version: 1.0.0
  Given no hashes to check 3 links for project 'jupyter': discarding no candidates
  Using version 1.0.0 (newest of versions: 1.0.0)
  Created temporary directory: /tmp/pip-unpack-i95zt6ip
  Starting new HTTPS connection (1): files.pythonhosted.org:443

And also logs from other runs

Collecting jupyter
  1 location(s) to search for versions of jupyter:
  * https://pypi.org/simple/jupyter/
  Getting page https://pypi.org/simple/jupyter/
  Found index url https://pypi.org/simple
  Starting new HTTPS connection (1): pypi.org:443

As you can see, it hangs on Starting new HTTPS connection (1): and sometimes it passes the first one but fails on second one.

I added --no-cache-dir and --default-timeout=1000 basing on other answers but it didn't help me. My pip install worked once but it was before I had -vvv option so don't know how it could complete, however my Dockerfile contains three pip install commands and later it failed on second one.

Big problem is that I'm not able to get the configuration of the machine that builds that docker image, when I tried it locally then everything was OK. I doesn't really matter if it's one pip install or many.

So, my question is: what could be a reason of pip hanging in that exact moment?

Tomasz
  • 658
  • 1
  • 7
  • 22

4 Answers4

16

Disabling IPv6 support on my machine solved it for me.
Works for ubuntu 20.04
Open the config file for setting system variables

sudo vi /etc/sysctl.conf

Add the following lines to the end

net.ipv6.conf.all.disable_ipv6 = 1 
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Load the settings

sudo sysctl -p

Verify the settings by viewing the disable_ipv6 flag. This should display 1 if it shows 0 one of the above steps failed

cat /proc/sys/net/ipv6/conf/all/disable_ipv6

Source: https://github.com/pypa/pip/issues/5469#issuecomment-393919476

Tim Menapace
  • 431
  • 4
  • 6
  • 1
    encountered on letbox: ipv6 was enabled but no public address was attached to it. disabling ipv6 altogether solved the issue indeed – scavenger Jan 30 '22 at 21:24
  • Instead, I set up an ipv6 address, can ping with no firewall, but no website access yet, so i fallback to disabling ipv6. :( ```ping ipv6.google.com PING ipv6.google.com(ams15s48-in-x0e.1e100.net (2a00:1450:400e:811::200e)) 56 data bytes 64 bytes from ams15s48-in-x0e.1e100.net (2a00:1450:400e:811::200e): icmp_seq=1 ttl=121 time=3.84 ms ``` – Konstantinos Apr 06 '23 at 10:38
  • Aaaah now it works fine. Great insight! First time in IPv6... Perfect! – Konstantinos Apr 06 '23 at 11:16
1

I could not figure how to use pip install in that environment, however I found a workaround.

There was a need to install anaconda(miniconda3) on that docker image and instead of using pip install I started using conda install for package management inside. It seems that conda did not have any problems so it was definetly a pip issue.

Tomasz
  • 658
  • 1
  • 7
  • 22
0

this should work:

FROM nvidia/cuda:10.1-base-ubuntu16.04

RUN apt-get update &&  apt-get install -y python3 python3-pip
RUN pip3 install --upgrade pip
RUN python3 -m pip --no-cache-dir --default-timeout=1000 install -U jupyter \
  jupyter_contrib_nbextensions \
  jupytext -vvv \

please note that will install python3.5 , that should work since jupyter works up from python3.3

LinPy
  • 16,987
  • 4
  • 43
  • 57
0

This might be related to being on a company network or VPN. Se this related question: Temporary failure in name resolution [Errno -3] with Docker

Andriod
  • 1,239
  • 12
  • 18