我有以下 dockerfile:
FROM debian:buster
#Configure apt to look at my Debian repository
COPY ./apt /etc/apt
#Install the software into the image
RUN apt-get update && apt-get -V -y dist-upgrade && apt-get -V -y --allow-unauthenticated --no-install-recommends --allow-downgrades install -f business=1.1-0
ENTRYPOINT ["/usr/sbin/main.sh"]
CMD []
所以基本上它从版本 1.1-0 安装包“business” 我在使用 docker 缓存时遇到问题,我正在推动具有相同版本 (1.1-0) 的包“business”的新代码更改 [是的,我正在覆盖版本……] 并且 docker 缓存不够智能,无法提取新的改变了.deb.
它使用缓存层而无需我的代码更改:皱眉: 作为解决方法,我使用 --no-cache 进行构建,但我不喜欢这个解决方案,因为我正在失去缓存机制。
有什么办法解决吗?我可以只从特定层构建没有缓存吗?
是的,你可以,
选项a)
RUN apt-get update && apt-get -V -y dist-upgrade
RUN head -c 23 /dev/urandom > /.randfile && apt-get -V -y --allow-unauthenticated --no-install-recommends --allow-downgrades install -f business=1.1-0
选项b)
--no-cache
docker-compose
和 docker build
的选项
(例如,在第一个管道中进行升级,推送为 someimage:baseimage,
然后在下一阶段使用FROM someimage:baseimage
选项c)