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/
无法找到满足要求瓶的版本(来自版本:)
找不到烧瓶的匹配分布
命令'/ bin / sh -c pip install flask redis'返回非零代码:1
我重启了所有内容,但仍然出现错误。 我的泊坞版版本是1.12.3。
谢谢!
答案 0 :(得分:-2)
您需要在docker config
中添加新的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