Docker RUN ls shows cached files

前端 未结 1 820
你的背包
你的背包 2021-01-19 08:15

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:

<         


        
相关标签:
1条回答
  • 2021-01-19 08:25

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

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

    docker build --no-cache ...
    

    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) ...
    

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

    0 讨论(0)
提交回复
热议问题