我在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