Disable cache for specific RUN commands

前端 未结 7 527
暗喜
暗喜 2020-11-30 05:16

I have a few RUN commands in my Dockerfile that I would like to run with -no-cache each time I build a Docker image.

I understand the

7条回答
  •  Happy的楠姐
    2020-11-30 05:53

    Use

    ADD "https://www.random.org/cgi-bin/randbyte?nbytes=10&format=h" skipcache
    

    before the RUN line you want to always run. This works because ADD will always fetch the file/URL and the above URL generates random data on each request, Docker then compares the result to see if it can use the cache.

    I have also tested this and works nicely since it does not require any additional Docker command line arguments and also works from a Docker-compose.yaml file :)

提交回复
热议问题