You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `buildctl` CLI does not automatically propagate the `$SOURCE_DATE_EPOCH` environment value from the client host to the `SOURCE_DATE_EPOCH` build arg.
181
+
However, higher level build tools, such as Docker Buildx (>= 0.10), may automatically capture the environment value.
182
+
183
+
The build arg value is used for:
184
+
- the `created` timestamp in the [OCI Image Config](https://github.com/opencontainers/image-spec/blob/main/config.md#properties)
185
+
- the `created` timestamp in the `history` objects in the [OCI Image Config](https://github.com/opencontainers/image-spec/blob/main/config.md#properties)
186
+
- the `org.opencontainers.image.created` annotation in the [OCI Image Index](https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys)
187
+
- the timestamp of the files exported with the `local` exporter
188
+
- the timestamp of the files exported with the `tar` exporter
189
+
190
+
The build arg value is not used for the timestamps of the files inside the image currently ([Caveats](#caveats)).
191
+
192
+
See also the [documentation](/frontend/dockerfile/docs/reference.md#buildkit-built-in-build-args) of the Dockerfile frontend.
193
+
194
+
## Caveats
195
+
### Timestamps of the files inside the image
196
+
Currently, the `SOURCE_DATE_EPOCH` value is not used for the timestamps of the files inside the image.
197
+
198
+
Workaround:
199
+
```dockerfile
200
+
# Limit the timestamp upper bound to SOURCE_DATE_EPOCH.
201
+
# Workaround for https://github.com/moby/buildkit/issues/3180
202
+
ARG SOURCE_DATE_EPOCH
203
+
RUN find $( ls / | grep -E -v "^(dev|mnt|proc|sys)$" ) -newermt "@${SOURCE_DATE_EPOCH}" -writable -xdev | xargs touch --date="@${SOURCE_DATE_EPOCH}" --no-dereference
204
+
```
205
+
206
+
The `touch` command above is [not effective](https://github.com/moby/buildkit/issues/3309) for mount point directories.
207
+
A workaround is to create mount point directories below `/dev` (tmpfs) so that the mount points will not be included in the image layer.
208
+
209
+
### Timestamps of whiteouts
210
+
Currently, the `SOURCE_DATE_EPOCH` value is not used for the timestamps of "whiteouts" that are created on removing files.
211
+
212
+
Workaround:
213
+
```dockerfile
214
+
# Squash the entire stage for resetting the whiteout timestamps.
215
+
# Workaround for https://github.com/moby/buildkit/issues/3168
216
+
FROM scratch
217
+
COPY --from=0 / /
218
+
```
219
+
220
+
The timestamps of the regular files in the original stage are maintained in the squashed stage, so you do not need to touch the files after this `COPY` instruction.
0 commit comments