diff options
| author | Bruce Ashfield <bruce.ashfield@gmail.com> | 2026-03-03 04:36:40 +0000 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2026-03-03 04:36:40 +0000 |
| commit | 6aef6e666245999a40d11366d5464b651460fee2 (patch) | |
| tree | 31f298430333ae2a657e9788dc2b691809f76935 | |
| parent | 139cd8a4916ce1291b883832077419c2660cb5df (diff) | |
| download | meta-virtualization-6aef6e666245999a40d11366d5464b651460fee2.tar.gz | |
image-oci: update oci-iamge-tools + runc instructions
Our runc is now sufficiently far ahead of the oci-image-tools
such that they aren't compatible.
But
They can still be made to work with a runc generated spec.
Update the comments to show a flow that works if using runc
directly is desired.
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
| -rw-r--r-- | classes/image-oci.bbclass | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/classes/image-oci.bbclass b/classes/image-oci.bbclass index ea2b63df..716b6f81 100644 --- a/classes/image-oci.bbclass +++ b/classes/image-oci.bbclass | |||
| @@ -10,11 +10,41 @@ | |||
| 10 | # | 10 | # |
| 11 | # Assuming the image name is "container-base": | 11 | # Assuming the image name is "container-base": |
| 12 | # | 12 | # |
| 13 | # If the oci image was a tarball, extract it (skip, if a directory is being directly used) | 13 | # If the oci image is a tarball, extract it to a temporary directory: |
| 14 | # % tar xvf container-base-<arch>-<stamp>.rootfs-oci-latest-x86_64-linux.oci-image.tar | 14 | # % mkdir -p t && tar xvf container-base-latest-oci.tar -C t |
| 15 | # | ||
| 16 | # Create the bundle from the deployed OCI directory symlink (resolve first): | ||
| 17 | # % oci-image-tool create --ref name=latest "$(readlink -f container-base-latest-oci)" container-base-oci-bundle | ||
| 18 | # | ||
| 19 | # (If using an extracted tar layout in ./t, this also works: | ||
| 20 | # % oci-image-tool create --ref name=latest t container-base-oci-bundle) | ||
| 21 | # | ||
| 22 | # NOTE: oci-image-tool may generate a minimal config.json that lacks the | ||
| 23 | # runtime mounts expected by modern runc. Generate a current runc spec and | ||
| 24 | # merge the image-derived process settings: | ||
| 25 | # | ||
| 26 | # % cd container-base-oci-bundle | ||
| 27 | # % cp config.json config.image.json | ||
| 28 | # % rm -f config.json | ||
| 29 | # % XDG_RUNTIME_DIR=/tmp runc spec | ||
| 30 | # % jq -s '\''.[0] as $img | .[1] as $base | $base | | ||
| 31 | # .root.path = ($img.root.path // "rootfs") | | ||
| 32 | # .process.args = ($img.process.args // $base.process.args) | | ||
| 33 | # .process.cwd = ($img.process.cwd // $base.process.cwd) | | ||
| 34 | # .process.user = ($img.process.user // $base.process.user) | | ||
| 35 | # .process.env = (($base.process.env // []) + ($img.process.env // []) | unique)'\'' \ | ||
| 36 | # config.image.json config.json > config.merged.json && mv config.merged.json config.json | ||
| 37 | # % cd .. | ||
| 15 | # | 38 | # |
| 16 | # And then create the bundle: | 39 | # If your build host architecture matches the target, you can execute the unbundled |
| 17 | # % oci-image-tool create --ref name=latest container-base-<arch>-<stamp>.rootfs-oci container-base-oci-bundle | 40 | # container with runc: |
| 41 | # % sudo runc run -b container-base-oci-bundle ctr-build | ||
| 42 | # / % uname -a | ||
| 43 | # Linux mrsdalloway 4.18.0-25-generic #26-Ubuntu SMP Mon Jun 24 09:32:08 UTC 2019 x86_64 GNU/Linux | ||
| 44 | # | ||
| 45 | # Cleanup between runs (if needed): | ||
| 46 | # % sudo runc delete -f ctr-build || true | ||
| 47 | # % sudo umount -Rl container-base-oci-bundle/rootfs 2>/dev/null || true | ||
| 18 | # | 48 | # |
| 19 | # Alternatively, the bundle can be created with umoci (use --rootless if sudo is not available) | 49 | # Alternatively, the bundle can be created with umoci (use --rootless if sudo is not available) |
| 20 | # % sudo umoci unpack --image container-base-<arch>-<stamp>.rootfs-oci:latest container-base-oci-bundle | 50 | # % sudo umoci unpack --image container-base-<arch>-<stamp>.rootfs-oci:latest container-base-oci-bundle |
| @@ -24,14 +54,6 @@ | |||
| 24 | # | 54 | # |
| 25 | # % skopeo copy --dest-creds <username>:<password> oci:container-base-<arch>-<stamp>:latest docker://zeddii/container-base | 55 | # % skopeo copy --dest-creds <username>:<password> oci:container-base-<arch>-<stamp>:latest docker://zeddii/container-base |
| 26 | # | 56 | # |
| 27 | # If your build host architecture matches the target, you can execute the unbundled | ||
| 28 | # container with runc: | ||
| 29 | # | ||
| 30 | # % sudo runc run -b container-base-oci-bundle ctr-build | ||
| 31 | # / % uname -a | ||
| 32 | # Linux mrsdalloway 4.18.0-25-generic #26-Ubuntu SMP Mon Jun 24 09:32:08 UTC 2019 x86_64 GNU/Linux | ||
| 33 | # | ||
| 34 | |||
| 35 | # We'd probably get this through the container image typdep, but just | 57 | # We'd probably get this through the container image typdep, but just |
| 36 | # to be sure, we'll repeat it here. | 58 | # to be sure, we'll repeat it here. |
| 37 | ROOTFS_BOOTSTRAP_INSTALL = "" | 59 | ROOTFS_BOOTSTRAP_INSTALL = "" |
| @@ -492,4 +514,3 @@ def oci_install_layer_packages(d, layer_rootfs, layer_packages, layer_name): | |||
| 492 | # the IMAGE_CMD:oci comes from the .inc | 514 | # the IMAGE_CMD:oci comes from the .inc |
| 493 | OCI_IMAGE_BACKEND_INC ?= "${@"image-oci-" + "${OCI_IMAGE_BACKEND}" + ".inc"}" | 515 | OCI_IMAGE_BACKEND_INC ?= "${@"image-oci-" + "${OCI_IMAGE_BACKEND}" + ".inc"}" |
| 494 | include ${OCI_IMAGE_BACKEND_INC} | 516 | include ${OCI_IMAGE_BACKEND_INC} |
| 495 | |||
