From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id CF10A1FF0B6 for ; Thu, 12 Nov 2026 15:16:50 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id ACF0E21671; Thu, 12 Nov 2026 15:16:47 +0100 (CET) From: Filip Schauer To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox 23/26] fix #7058: oci: add compatibility for Docker Image Manifest V2 Date: Thu, 12 Nov 2026 15:10:50 +0100 Message-ID: <20261112141109.137298-24-f.schauer@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261112141109.137298-1-f.schauer@proxmox.com> References: <20261112141109.137298-1-f.schauer@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794492990961 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.166 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: WOLCBEVFBS7I75U222ERXQFP5L34PNSL X-Message-ID-Hash: WOLCBEVFBS7I75U222ERXQFP5L34PNSL X-MailFrom: f.schauer@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Many container registries and build tools use Docker Image Manifest V2 media types instead of pure OCI media types. This caused pulling or extracting such images to fail due to unexpected media types. Add compatibility by accepting the corresponding Docker Image Manifest V2 media types alongside the OCI media types. To test this on an OCI TAR archive, one can use Docker to generate an OCI image with Docker media types: cat << 'EOF' > Dockerfile FROM alpine:3.18 CMD ["sh"] EOF docker buildx build \ --output type=oci,dest=out.tar,oci-mediatypes=false . To test pulling an OCI image with a Docker Manifest List from a registry, one can pull `grafana/grafana:13.2-slim` from Docker Hub. Signed-off-by: Filip Schauer --- proxmox-oci/src/client.rs | 16 +++++++++++++--- proxmox-oci/src/extract.rs | 13 +++++++++++-- proxmox-oci/src/lib.rs | 14 ++++++++++++-- proxmox-oci/src/oci_tar_image.rs | 5 +++-- proxmox-oci/src/parse.rs | 7 +++++-- 5 files changed, 44 insertions(+), 11 deletions(-) diff --git a/proxmox-oci/src/client.rs b/proxmox-oci/src/client.rs index c6d15cbc..5d5beb8c 100644 --- a/proxmox-oci/src/client.rs +++ b/proxmox-oci/src/client.rs @@ -11,6 +11,7 @@ use oci_spec::OciSpecError; use oci_spec::distribution::{ErrorResponse, Reference, TagList}; use oci_spec::image::{ Arch, Descriptor, Digest, ImageConfiguration, ImageIndex, ImageManifest, MediaType, Os, + ToDockerV2S2, }; use proxmox_http::client::sync; use proxmox_http::{HttpClient, HttpOptions, ProxyConfig}; @@ -405,10 +406,14 @@ impl Client { &[ MediaType::ImageManifest.as_ref(), MediaType::ImageIndex.as_ref(), + MediaType::ImageManifest.to_docker_v2s2().unwrap(), + MediaType::ImageIndex.to_docker_v2s2().unwrap(), ], )?; - if matches!(media_type, MediaType::ImageIndex) { + if media_type == MediaType::ImageIndex + || media_type.as_ref() == MediaType::ImageIndex.to_docker_v2s2().unwrap() + { let index = ImageIndex::from_reader(Cursor::new(&body))?; let manifest_digest = index @@ -423,8 +428,13 @@ impl Client { .ok_or(OciClientError::NoMatchingManifest)?; let manifest_reference = image.clone_with_digest(manifest_digest.to_string()); - let (manifest_raw, manifest_digest, _) = - self.pull_manifest_raw(&manifest_reference, &[MediaType::ImageManifest.as_ref()])?; + let (manifest_raw, manifest_digest, _) = self.pull_manifest_raw( + &manifest_reference, + &[ + MediaType::ImageManifest.as_ref(), + MediaType::ImageManifest.to_docker_v2s2().unwrap(), + ], + )?; let manifest = ImageManifest::from_reader(Cursor::new(&manifest_raw))?; Ok(DigestedImageManifest { diff --git a/proxmox-oci/src/extract.rs b/proxmox-oci/src/extract.rs index 979c93eb..0bb272c3 100644 --- a/proxmox-oci/src/extract.rs +++ b/proxmox-oci/src/extract.rs @@ -9,7 +9,7 @@ use std::time::{Duration, UNIX_EPOCH}; use flate2::read::GzDecoder; use nix::sys::stat::{Mode, SFlag, makedev, mknod}; -use oci_spec::image::{ImageConfiguration, ImageManifest, MediaType}; +use oci_spec::image::{ImageConfiguration, ImageManifest, MediaType, ToDockerV2S2}; use tar::{Archive, EntryType}; use thiserror::Error; @@ -52,8 +52,17 @@ pub(crate) fn extract_image_rootfs>( ExtractError::MissingLayerFile(layer_descriptor.digest().clone()), )?; + let media_type = match layer_descriptor.media_type() { + MediaType::Other(other) + if other == MediaType::ImageLayerGzip.to_docker_v2s2().unwrap() => + { + &MediaType::ImageLayerGzip + } + other => other, + }; + type DecodeFn = Box Fn(&'a mut T) -> io::Result>>; - let decode_fn: DecodeFn> = match layer_descriptor.media_type() { + let decode_fn: DecodeFn> = match media_type { MediaType::ImageLayer | MediaType::ImageLayerNonDistributable => { Box::new(|file| Ok(Box::new(file))) } diff --git a/proxmox-oci/src/lib.rs b/proxmox-oci/src/lib.rs index d7680cce..cd798fe3 100644 --- a/proxmox-oci/src/lib.rs +++ b/proxmox-oci/src/lib.rs @@ -7,7 +7,7 @@ use flate2::read::GzDecoder; use oci_spec::OciSpecError; pub use oci_spec::distribution::Reference; pub use oci_spec::image::{Arch, Config, Os}; -use oci_spec::image::{Descriptor, ImageIndexBuilder, MediaType, OciLayoutBuilder}; +use oci_spec::image::{Descriptor, ImageIndexBuilder, MediaType, OciLayoutBuilder, ToDockerV2S2}; use thiserror::Error; use proxmox_lang::try_block; @@ -243,7 +243,17 @@ pub fn pull_image_to_oci_storage( } else { println!("Pulling blob {blob_digest}"); let layer_reader = client.pull_blob_reader(reference, layer)?; - let mut uncompressed_blob = match layer.media_type() { + + let media_type = match layer.media_type() { + MediaType::Other(other) + if other == MediaType::ImageLayerGzip.to_docker_v2s2().unwrap() => + { + &MediaType::ImageLayerGzip + } + other => other, + }; + + let mut uncompressed_blob = match media_type { MediaType::ImageLayer | MediaType::ImageLayerNonDistributable => { if blob_digest != &diff_id { return Err(PullToStorageError::Digest(DigestError::Mismatch { diff --git a/proxmox-oci/src/oci_tar_image.rs b/proxmox-oci/src/oci_tar_image.rs index f51556e9..cca9da72 100644 --- a/proxmox-oci/src/oci_tar_image.rs +++ b/proxmox-oci/src/oci_tar_image.rs @@ -4,7 +4,7 @@ use std::ops::Range; use std::path::{Path, PathBuf}; use oci_spec::OciSpecError; -use oci_spec::image::{Arch, Digest, ImageIndex, ImageManifest, MediaType, Os}; +use oci_spec::image::{Arch, Digest, ImageIndex, ImageManifest, MediaType, Os, ToDockerV2S2}; use tar::Archive; use proxmox_io::RangeReader; @@ -77,7 +77,8 @@ impl OciTarImage { architecture: Option<&Arch>, ) -> Option> { let digest = match self.image_index.manifests().iter().find(|d| { - d.media_type() == &MediaType::ImageManifest + (d.media_type() == &MediaType::ImageManifest + || d.media_type().as_ref() == MediaType::ImageManifest.to_docker_v2s2().unwrap()) && d.platform().as_ref().is_none_or(|p| { architecture.is_none_or(|a| p.architecture() == a) && os.is_none_or(|os| p.os() == os) diff --git a/proxmox-oci/src/parse.rs b/proxmox-oci/src/parse.rs index af669d38..1dc4eea2 100644 --- a/proxmox-oci/src/parse.rs +++ b/proxmox-oci/src/parse.rs @@ -2,7 +2,7 @@ use std::fs::File; use std::path::Path; use oci_spec::OciSpecError; -use oci_spec::image::{Arch, ImageConfiguration, ImageManifest, MediaType, Os}; +use oci_spec::image::{Arch, ImageConfiguration, ImageManifest, MediaType, Os, ToDockerV2S2}; use thiserror::Error; use crate::oci_tar_image::OciTarImage; @@ -35,7 +35,10 @@ pub(crate) fn parse_image>( let image_config_descriptor = image_manifest.config(); - if image_config_descriptor.media_type() != &MediaType::ImageConfig { + if image_config_descriptor.media_type() != &MediaType::ImageConfig + && image_config_descriptor.media_type().as_ref() + != MediaType::ImageConfig.to_docker_v2s2().unwrap() + { return Err(ParseError::WrongMediaType); } -- 2.47.3