Answers:
这是因为映像中没有包缓存,因此需要运行:
apt-get update
在安装软件包之前,并且如果您的命令在Dockerfile中,则需要:
apt-get -y install curl
要取消命令的标准输出,请使用-qq。例如
apt-get -qq -y install curl
docker image prune腾出空间,这对我来说是固定的。
从文档在5月2017年 2018年 2019年 2020年
始终
RUN apt-get update与apt-get install同RUN一条语句结合使用,例如
RUN apt-get update && apt-get install -y package-bar(...)
apt-get update在RUN语句中单独使用会导致缓存问题,并且后续apt-get install指令会失败。(...)
使用
RUN apt-get update && apt-get install -y确保您的Dockerfile安装了最新的软件包版本,而无需进一步的编码或手动干预。这种技术称为“缓存清除”。
在Dockerfile中添加以下命令:
RUN apt-get update