gpt4 book ai didi

Docker缓存导致误报释放

转载 作者:行者123 更新时间:2023-12-03 07:57:47 24 4
gpt4 key购买 nike

我有以下 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)

  • 分割你的 dockerfile ,在未缓存的命令中生成一个随机结果:
    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)

  • use multi-staged builds ,但生成第二张图像docker-composedocker build--no-cache 选项(例如,在第一个管道中进行升级,作为 someimage:baseimage 推送,然后在下一阶段使用FROM someimage:baseimage

选项c)

关于Docker缓存导致误报释放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75604031/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com