求教一个 docker 里 pip install 的问题

2016-07-02 11:17:07 +08:00
 kkzxak47

在 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 有关系?

16210 次点击
所在节点    Docker
3 条回复
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
2016-07-11 01:03:39 +08:00
@iwishing 嗯,我重建了个 droplet 就好了,忘记回来更新了
kkzxak47
2016-08-08 06:10:18 +08:00
其实是内存不足,进程被杀了,这个出错信息也是有意思哈

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/289777

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX