caching - How can I prevent a Dockerfile instruction from being cached? -


in dockerfile use curl or add download latest version of archive like:

from debian:jessie ... run apt-get install -y curl ... run curl -sl http://example.com/latest/archive.tar.gz --output archive.tar.gz ... add http://example.com/latest/archive2.tar.gz ... 

the run statement uses curl or add creates own image layer. used cache future executions of docker build.

question: how can disable caching instructions?

it great cache invalidation working there. e.g. using http etags or querying last modified header field. give possibility quick check based on http headers decide whether cached layer used or not.

i know dirty tricks e.g. executing download shell script in run statement instead. filename changed before docker build triggered our build system. , http checks inside script. need store either last used etag or last modified file somewhere. wondering whether there more clean , native docker functionality use, here.

a build-time argument can specified forcibly break cache step onwards. example, in dockerfile, put

arg cache_date=not_a_date 

and gives argument fresh value on every new build. best, of course, timestamp.

docker build --build-arg cache_date=$(date +%y-%m-%d:%h:%m:%s) ... 

make sure value string without spaces, otherwise docker client falsely take multiple arguments.

see detailed discussion on issue 22832.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -