我按照https://docker-curriculum.com/中的教程生成我的第一個Docker鏡像。在第2.4節中,我們將學習如何使用基本映像python:3-onbuild
來配置一個簡單的Dockerfile,它將自動運行pip並安裝requirements.txt
的依賴關係。Docker課程教程,python pip失敗
的問題是,當我嘗試建立搬運工,包裝簡單地加載失敗:
[email protected]:~/workspace/docker-curriculum/flask-app$ docker build -t prakhar1989/catnip .
Sending build context to Docker daemon 8.704kB
Step 1/3 : FROM python:3-onbuild
# Executing 3 build triggers...
Step 1/1 : COPY requirements.txt /usr/src/app/
---> Using cache
Step 1/1 : RUN pip install --no-cache-dir -r requirements.txt
---> Running in 74c4e94fa1ba
Collecting Flask (from -r requirements.txt (line 1))
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fc6592831d0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /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 0x7fc659283cc0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /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 0x7fc659283208>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /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 0x7fc659283470>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /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 0x7fc659283ba8>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/flask/
Could not find a version that satisfies the requirement Flask (from -r requirements.txt (line 1)) (from versions:)
No matching distribution found for Flask (from -r requirements.txt (line 1))
The command '/bin/sh -c pip install --no-cache-dir -r requirements.txt' returned a non-zero code: 1
[email protected]:~/workspace/docker-curriculum/flask-app$
我已經採取了看看這個stackoverflow solution。這些答案似乎已經解決了許多人無法與域名服務器(DNS)連接的問題,但重置碼頭或添加DNS到/etc/dhcp/dhclient.conf
沒有爲我做任何事情。
我已經安裝了Docker版本17.09.0-ce
並且在Ubuntu 16.04
上運行,有什麼想法?
@JanezKuhar這似乎不是問題,因爲我正在拉一個'用戶圖像',它就像克隆某人的存儲庫。我也嘗試了你的解決方案,這導致了相同的結果 – Max
錯誤信息表明嘗試訪問https://pypi.python.org/pypi時出現連接錯誤。您正在構建圖像的機器是否可以連接到該網站? – jwodder
不,我不能。本質上問題是我無法連接到服務器,因爲我的機器找不到正確的DNS。但在SO解決方案中嘗試解決方案後,我仍然無法連接 – Max