Skip to content

containertool: Use epoch date in image metadata #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

euanh
Copy link
Collaborator

@euanh euanh commented Dec 4, 2024

Motivation

The registry is a content-addressable store in which objects are identified by their hashes. Many objects, such as image manifests, contain timestamp fields. A difference in a timestamp field will cause otherwise identical objects to have different hashes, causing a variety of problems:

  • an image cannot be verified by rebuilding it from the same original parts and comparing the result
  • the registry cannot completely deduplicate two images with almost identical contents because their hashes do not match, wasting storage and network bandwidth (some block-level deduplication may still be possible, but clients which already have one image will have to pull the other in its entirety)

These problems can be avoided by setting timestamp fields to fixed values, often the Unix epoch: https://reproducible-builds.org/docs/source-date-epoch/

Modifications

Set the overall image manifest timestamp and the timestamp used in the image history log to the Unix epoch.

containertool already sets file modification times to the epoch when creating image layers.

Result

An image packaging the same executable will have the same hash when built at different times on the same machine or different machines.

Test Plan

  • All existing tests, including end to end tests, continue to pass.
  • Manually verified that repeated builds produces images with identical hashes.

@euanh euanh added kind/enhancement New feature or request area/interoperability Improvements to compatibility with other systems. semver/minor Adds new public API. labels Dec 4, 2024
@euanh euanh force-pushed the reproducible-images branch from 96ba497 to 2287ae6 Compare December 6, 2024 09:15
@euanh euanh marked this pull request as ready for review December 6, 2024 14:46
@euanh euanh merged commit 13702bc into apple:main Dec 6, 2024
17 checks passed
@euanh euanh deleted the reproducible-images branch December 6, 2024 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/interoperability Improvements to compatibility with other systems. kind/enhancement New feature or request semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant