Add container image import to create an image from a rootfs tarball#1772
Open
muk2 wants to merge 1 commit into
Open
Add container image import to create an image from a rootfs tarball#1772muk2 wants to merge 1 commit into
container image import to create an image from a rootfs tarball#1772muk2 wants to merge 1 commit into
Conversation
Implements a new `container image import <tarball> <reference>` subcommand, analogous to `docker import`. The input archive (plain `.tar` or a compressed `.tar.gz`/`.tar.zst`/...) is treated as a single image layer: it is extracted, re-archived into a canonical uncompressed tar (to compute the layer diffID) and a gzip-compressed tar (the layer blob), and a minimal OCI config, manifest, and index are synthesized and written to the content store before registering the image reference in the image store. The layer-building core lives in `ImageImporter` and is exercised by a unit test in the new `ContainerImagesServiceTests` target. Fixes apple#426
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
container image import <tarball> <reference>— the analog ofdocker import— which builds a single-layer OCI image from a root filesystemtarball (
.taror.tar.gz, compression auto-detected). The resulting image istagged with the given reference and can be run like any other image.
Testing
make checkpasses (formatting + license headers).ImageImporterTestsverify that the importer produces awell-formed index -> manifest -> config -> single layer with a
sha256:diffID.Passes.
tar -cf rootfs.tar -C rootfs .thencontainer image import rootfs.tar myimg:latest; the image appears incontainer image lsandcontainer run --rm myimg:latest cat /hello.txtprints the expected file contents.
Fixes #426