all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Filip Schauer <f.schauer@proxmox.com>
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	[thread overview]
Message-ID: <20261112141109.137298-24-f.schauer@proxmox.com> (raw)
In-Reply-To: <20261112141109.137298-1-f.schauer@proxmox.com>

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 <f.schauer@proxmox.com>
---
 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<R: Read + Seek, P: AsRef<Path>>(
             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<T> = Box<dyn for<'a> Fn(&'a mut T) -> io::Result<Box<dyn Read + 'a>>>;
-        let decode_fn: DecodeFn<OciTarImageBlob<R>> = match layer_descriptor.media_type() {
+        let decode_fn: DecodeFn<OciTarImageBlob<R>> = 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<R: Read + Seek> OciTarImage<R> {
         architecture: Option<&Arch>,
     ) -> Option<oci_spec::Result<ImageManifest>> {
         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<P: AsRef<Path>>(
 
     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





  parent reply	other threads:[~2026-11-12 14:16 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 14:10 [PATCH container/manager/proxmox{,-perl-rs}/storage 00/26] oci: add native registry client and prepare for OverlayFS Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox-perl-rs 01/26] pve-rs: oci: update doc comment of parse_and_extract_image Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 02/26] oci: rename error when no manifest can be selected Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 03/26] oci: add `os` parameter to parse_and_extract_image Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox-perl-rs 04/26] pve-rs: " Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 05/26] oci: add a digest helper module Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 06/26] oci: reduce redundant layer decompression during extraction Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 07/26] oci: factor out parsing and extraction into modules Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 08/26] oci: explicitly set mtime of directories when extracting layer Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 09/26] oci: add a registry client Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 10/26] oci: add a public list_repository_tags function Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox-perl-rs 11/26] pve-rs: oci: expose list_repository_tags Filip Schauer
2026-11-12 14:10 ` [PATCH manager 12/26] use proxmox-oci instead of skopeo for listing tags from OCI registries Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 13/26] oci: rename parse_and_extract_image to be tar-specific Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox-perl-rs 14/26] pve-rs: " Filip Schauer
2026-11-12 14:10 ` [PATCH container 15/26] oci create: " Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 16/26] oci: rename ProxmoxOciError to ParseAndExtractTarError Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 17/26] oci: add a public pull_image_as_tar function Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox-perl-rs 18/26] pve-rs: oci: expose pull_image_as_tar Filip Schauer
2026-11-12 14:10 ` [PATCH storage 19/26] use proxmox-oci instead of skopeo for pulling from OCI registries Filip Schauer
2026-11-12 14:10 ` [PATCH storage 20/26] api: oci image pull: fix temp file cleanup on task stop Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 21/26] oci: add a public pull_image_to_oci_storage function Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox-perl-rs 22/26] pve-rs: oci: expose pull_image_to_oci_storage Filip Schauer
2026-11-12 14:10 ` Filip Schauer [this message]
2026-11-12 14:10 ` [PATCH proxmox 24/26] oci: include media type in ParseError::WrongMediaType Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox 25/26] oci: add public functions for removing OCI images Filip Schauer
2026-11-12 14:10 ` [PATCH proxmox-perl-rs 26/26] pve-rs: oci: expose " Filip Schauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261112141109.137298-24-f.schauer@proxmox.com \
    --to=f.schauer@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal