我在Docker上安裝了Ubuntu 14.04鏡像。之後,當我嘗試在Ubuntu映像中安裝軟件包時,我無法找到軟件包錯誤:無法在Docker中安裝軟件包Ubuntu鏡像
apt-get install curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package curl
如何解決此錯誤?
我在Docker上安裝了Ubuntu 14.04鏡像。之後,當我嘗試在Ubuntu映像中安裝軟件包時,我無法找到軟件包錯誤:無法在Docker中安裝軟件包Ubuntu鏡像
apt-get install curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package curl
如何解決此錯誤?
這是因爲圖像沒有包緩存,你需要運行:
apt-get -qq update
安裝軟件包前,如果你的命令是在Dockerfile,你這時就需要:
在Dockerfileapt-get -qq -y install curl
添加下面的命令: 運行apt-get更新
從docs在2017年三月:
Always combine
RUN apt-get update
withapt-get install
in the sameRUN
statement, for example
RUN apt-get update && apt-get install -y package-bar
(...)
Using
apt-get update
alone in aRUN
statement causes caching issues and subsequentapt-get install
instructions fail.
這個工作對我來說,我應該跑-qq所有時間 – 2014-12-03 14:03:17
-qq抑制你通常Dockerfile不需要輸出。另一個不錯的技巧 - 告訴debconf它在非交互式環境中工作: echo'debconf debconf/frontend select Noninteractive'| debconf-set-selections – ISanych 2014-12-03 14:11:28
出於某種原因,這對我不起作用,仍然是相同的「E:無法找到包..」消息 – tblancog 2016-08-28 02:48:00