File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
content/manuals/build/cache Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,23 @@ If your build contains several layers and you want to ensure the build cache is
4444reusable, order the instructions from less frequently changed to more
4545frequently changed where possible.
4646
47+ ## WORKDIR and SOURCE_DATE_EPOCH
48+
49+ The ` WORKDIR ` instruction respects the ` SOURCE_DATE_EPOCH ` build argument when
50+ determining cache validity. Changing ` SOURCE_DATE_EPOCH ` between builds
51+ invalidates the cache for ` WORKDIR ` and all subsequent instructions.
52+
53+ ` SOURCE_DATE_EPOCH ` sets timestamps for files created during the build. If you
54+ set this to a dynamic value like a Git commit timestamp, the cache breaks with
55+ each commit. This is expected behavior when tracking build provenance.
56+
57+ For reproducible builds without frequent cache invalidation, use a fixed
58+ timestamp:
59+
60+ ``` console
61+ $ docker build --build-arg SOURCE_DATE_EPOCH=0 .
62+ ```
63+
4764## RUN instructions
4865
4966The cache for ` RUN ` instructions isn't invalidated automatically between builds.
You can’t perform that action at this time.
0 commit comments