卸载 Dockerfile 中的 RUN 缓存类型挂载

问题描述 投票:0回答:1

在 Dockerfile 中,我正在安装缓存:

RUN  --mount=type=cache,target=/opt/conda/pkgs \
     ...

我希望这个坐骑在任一个期间都有效

  1. 只是这个运行命令
  2. 直到再往下几层卸下

有没有办法做到这一点?

我在文档中找不到任何参考资料。

docker caching dockerfile mount unmount
1个回答
0
投票

尝试使用多阶段 Dockerfile

例如:-

FROM BASE_IMAGE:tag AS base
RUN  --mount=type=cache,target=/opt/conda/pkgs \
 ...


FROM BASE_IMAGE:tag AS app
RUN mkdir /some/place
COPY --from=base "/opt/conda/pkgs"
© www.soinside.com 2019 - 2024. All rights reserved.