Docker RUN ls显示缓存的文件 [英] Docker RUN ls shows cached files

查看:692
本文介绍了Docker RUN ls显示缓存的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置一个docker容器,并使用 RUN ls 进行调试。但是,当我运行 RUN ls 时,码头工人会打印出以下内容:

I am trying to setup a docker container and am using RUN ls to help debug. However, when I run RUN ls, docker prints out the following:

 ---> Using cache
 ---> 96223b1b0748

我希望它注销该文件夹中的文件。有人知道怎么回事吗?

I am expecting it to log out files in the folder. Does anyone know what might be happening?

这是我完整的Dockerfile:

Here is my full Dockerfile:

FROM node:latest 

WORKDIR /app

COPY app .

RUN ls

谢谢!

推荐答案

Docker缓存最近构建的层,以便后续构建可以重用它们。

Docker caches recently built layers so that subsequent builds can reuse them.

最简单的方法打破这种行为是在构建过程中使用-no-cache 标志:

The simplest way to break this behavior is to use the --no-cache flag during build:

docker build --no-cache ...

但是,这会使所有缓存层失效。如果您仍想在 RUN ls 指令之前为图层使用缓存的图层,则可以在其前面放置以下行:

However this will invalidate all cached layers. If you still want to use cached layers for layers before the RUN ls instruction, you can put the following line before it:

ARG CACHE_TS=default_ts

然后给出此参数每个新构建的新值:

And then gives this argument a new value on every new build:

docker build --build-arg CACHE_TS=$(date +%s) ...

请参阅以下Github问题: https://github.com/moby/moby/issues/22832

Please see this Github issue: https://github.com/moby/moby/issues/22832

这篇关于Docker RUN ls显示缓存的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆