V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
kkzxak47
V2EX  ›  Docker

求教一个 docker 里 pip install 的问题

  •  
  •   kkzxak47 · 2016-07-02 11:17:07 +08:00 · 16346 次点击
    这是一个创建于 3072 天前的主题,其中的信息可能已经有所发展或是发生改变。

    在 digitalocean sfo 机房的 ubuntu14.04 上配 docker 里的 django ,在系统里直接安装没任何问题:

    pip install Django==1.8.13 --no-cache-dir --ignore-installed                                 
    Collecting Django==1.8.13
      Downloading Django-1.8.13-py2.py3-none-any.whl (6.2MB)
        100% |################################| 6.2MB 6.8MB/s 
    Installing collected packages: Django
    Successfully installed Django-1.8.13
    

    但是 docker 就不行了:

    Step 6 : RUN pip install -r requirements.txt
     ---> Running in 6d2f65927b6f
    Collecting Django==1.8.13 (from -r requirements.txt (line 1))
      Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.con
    nection.VerifiedHTTPSConnection object at 0x7fe9e3085f28>, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/django/
      Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.con
    nection.VerifiedHTTPSConnection object at 0x7fe9e3085898>, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/django/
      Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.con
    nection.VerifiedHTTPSConnection object at 0x7fe9e30858d0>, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/django/
      Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.con
    nection.VerifiedHTTPSConnection object at 0x7fe9e30851d0>, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/django/
      Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.con
    nection.VerifiedHTTPSConnection object at 0x7fe9e47c8160>, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/django/
      Could not find a version that satisfies the requirement Django==1.8.13 (from -r requirements.txt (line 1)) (from versions: )
    No matching distribution found for Django==1.8.13 (from -r requirements.txt (line 1))
    ERROR: Service 'web' failed to build: The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1
    

    Dockerfile 是这样:

    FROM python:3.5
    ENV PYTHONUNBUFFERED 1
    RUN mkdir /usr/src/app
    RUN mkdir /usr/log
    WORKDIR /usr/src/app
    ADD . /usr/src/app
    RUN pip install -r requirements.txt
    

    可能是什么地方的问题,是不是跟 python3.5 更新到 3.5.2 有关系?

    3 条回复    2016-08-08 06:10:18 +08:00
    iwishing
        1
    iwishing  
       2016-07-10 19:13:22 +08:00
    docker 装没问题啊

    root@ubuntudev:~/test# docker build .
    Sending build context to Docker daemon 3.072 kB
    Step 1 : FROM python:3.5
    ---> cf9db56faafa
    Step 2 : ENV PYTHONUNBUFFERED 1
    ---> Using cache
    ---> 59337f3b0849
    Step 3 : RUN mkdir /usr/src/app
    ---> Using cache
    ---> d8b5fcadfd9f
    Step 4 : RUN mkdir /usr/log
    ---> Using cache
    ---> d5af0c84406e
    Step 5 : WORKDIR /usr/src/app
    ---> Using cache
    ---> 43813190de59
    Step 6 : ADD . /usr/src/app
    ---> 7b9ab61b6512
    Removing intermediate container d3a9f1b4eebf
    Step 7 : RUN pip install -r requirements.txt
    ---> Running in 5e174f556631
    Collecting Django==1.8.13 (from -r requirements.txt (line 1))
    Downloading Django-1.8.13-py2.py3-none-any.whl (6.2MB)

    Installing collected packages: Django
    Successfully installed Django-1.8.13
    ---> a405a0263b58
    Removing intermediate container 5e174f556631
    Successfully built a405a0263b58
    kkzxak47
        2
    kkzxak47  
    OP
       2016-07-11 01:03:39 +08:00 via Android
    @iwishing 嗯,我重建了个 droplet 就好了,忘记回来更新了
    kkzxak47
        3
    kkzxak47  
    OP
       2016-08-08 06:10:18 +08:00
    其实是内存不足,进程被杀了,这个出错信息也是有意思哈
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2816 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 14:31 · PVG 22:31 · LAX 06:31 · JFK 09:31
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.