Docker运行“RUN pip install flask”时失败,Docker文件内容如下:
FROM python:3.4
RUN mkdir /code
COPY app.py /code/app.py
WORKDIR /code
RUN pip install flask redis
CMD ['python', 'app.py']
**When I run in the terminal : "$ sudo docker build -t fig_ex .", it shows:**
Sending build context to Docker daemon 3.072 kB
Step 1 : FROM python:3.4
---> d87c6dbd17a7
Step 2 : RUN mkdir /code
---> Using cache
---> 4049bfe07335
Step 3 : COPY app.py /code/app.py
---> Using cache
---> bbe0353172b6
Step 4 : WORKDIR /code
---> Using cache
---> 2535608c604c
Step 5 : RUN pip install flask redis
---> Running in 4a49dee8c8b1
收集瓶
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f0f88deec18>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/flask/
Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f0f88dee2b0>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/flask/
Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f0f88dee908>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/flask/
Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f0f88dd0978>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/flask/
Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f0f8914d630>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/flask/
找不到满足需求量瓶的版本(来自版本:)
找不到 flask 的匹配分布
命令'/ bin / sh -c pip install flask redis'返回非零代码:1
我已经重新启动了一切,错误仍然出现。
我的Docker版本是1.12.3。
谢谢 !
最佳答案
对于Ubuntu用户
您需要在docker配置中添加新的DNS地址
sudo nano /lib/systemd/system/docker.service
在ExecStar
之后添加dns。 --dns 10.252.252.252 --dns 10.253.253.253
应该看起来像这样:ExecStart=/usr/bin/dockerd -H fd:// --dns 10.252.252.252 --dns 10.253.253.253
systemctl daemon-reload
sudo service docker restart
关于docker - 无法建立新连接:[Errno -2]名称或服务未知,')':/simple/flask/,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42064246/