8000 Add docker media types in OCI formats by brbayes-msft · Pull Request #2695 · containers/image · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add docker media types in OCI formats #2695

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
Feb 12, 2025

Conversation

brbayes-msft
Copy link
Contributor

This pull request adds the docker media types when reading back OCI formats, along with the corresponding tests. This is from running into cases where docker images were built with the docker media types. To avoid having to convert all of the existing manifests so that the original types can be maintained, this code adds support for reading the docker specific formats since the OCI formats are backwards compatible with the docker formats (https://github.com/opencontainers/image-spec/blob/main/media-types.md).

@brbayes-msft brbayes-msft marked this pull request as ready for review January 23, 2025 18:36
@mtrmac
Copy link
Collaborator
mtrmac commented Jan 27, 2025

Thanks. At a high level, I’m really unsure.

For reading images, sure, that’s ~easy enough. But are the users 8000 then going to ask to also supporting writes with non-OCI images? Does the DeleteImage code need to be able to handle non-OCI media types?

Approximately, I generally think that any producer creating an OCI-layout directory structure is obviously aware of OCI, so I don’t know why any new user of this code should start to want to support pre-OCI images.

What’s the use case?

If the goal were to write some kind of general-purpose image storage mechanism, note that the OCI transport (currently) can’t do that, e.g. it doesn’t support reading/writing signatures along with the image.

@brbayes-msft
Copy link
Contributor Author

The main issue I'm looking to address here is cases where tooling such as the Docker Daemon pull existing images from upstreams, and those upstream images still use docker media types. With the recent switch for the Docker Daemon to save dual format archives (both oci and docker archive), we run into an issue where the archive is still an OCI layout, but it maintained its original media types, thus breaking tools like Skopeo.

I do agree that when creating OCI layouts, the creator is likely aware of the OCI types and should conform to them when possible. That's why I focused primarily on only read operations so as to better handle the case where tooling changes the wrapper. That being said, if there are other areas of the code that I should fill out, I'm happy to do so.

@brbayes-msft
Copy link
Contributor Author

@mtrmac Sorry to ping you, but I'd like to follow up here if there is a path forward to supporting the docker media types.

@mtrmac
Copy link
Collaborator
mtrmac commented Feb 3, 2025

I’m sorry, I couldn’t return to look into this in detail — but, the short version of it is that if docker save (or something similar?) produces such archives, then I do agree that it is valuable to be able to consume them.

@brbayes-msft brbayes-msft requested a review from mtrmac February 4, 2025 19:47
@brbayes-msft
Copy link
Contributor Author

@mtrmac Sorry to bump this again. I updated the PR after your comments on V2S1. Let me know if there's any other changes I should add.

@mtrmac
Copy link
Collaborator
mtrmac commented Feb 10, 2025

With the recent switch for the Docker Daemon to save dual format archives (both oci and docker archive), we run into an issue where the archive is still an OCI layout, but it maintained its original media types, thus breaking tools like Skopeo.

I can’t reproduce this:

# rpm -q moby-engine skopeo
moby-engine-27.3.1-2.fc41.x86_64
skopeo-1.17.0-1.fc41.x86_64
# skopeo inspect docker://quay.io/libpod/alpine | jq '.Digest,.LayersData[].MIMEType' 
"sha256:fa93b01658e3a5a1686dc3ae55f170d8de487006fb53a28efcd12ab0710a2e5f"
"application/vnd.docker.image.rootfs.diff.tar.gzip"
# docker pull quay.io/libpod/alpine

# docker save -o foo.tar quay.io/libpod/alpine
# skopeo inspect --raw oci-archive:foo.tar | jq -r .mediaType
application/vnd.oci.image.manifest.v1+json

(and extracting the archive, index.json uses OCI MIME types throughout).

Is there some other way this can be created using Docker?

@brbayes-msft
Copy link
Contributor Author

With the recent switch for the Docker Daemon to save dual format archives (both oci and docker archive), we run into an issue where the archive is still an OCI layout, but it maintained its original media types, thus breaking tools like Skopeo.

I can’t reproduce this:

# rpm -q moby-engine skopeo
moby-engine-27.3.1-2.fc41.x86_64
skopeo-1.17.0-1.fc41.x86_64
# skopeo inspect docker://quay.io/libpod/alpine | jq '.Digest,.LayersData[].MIMEType' 
"sha256:fa93b01658e3a5a1686dc3ae55f170d8de487006fb53a28efcd12ab0710a2e5f"
"application/vnd.docker.image.rootfs.diff.tar.gzip"
# docker pull quay.io/libpod/alpine
…
# docker save -o foo.tar quay.io/libpod/alpine
# skopeo inspect --raw oci-archive:foo.tar | jq -r .mediaType
application/vnd.oci.image.manifest.v1+json

(and extracting the archive, index.json uses OCI MIME types throughout).

Is there some other way this can be created using Docker?

I see different behavior on my machine. I run Windows, though we have run into this on Linux hosts as well.

PS C:\Users\brbayes\Downloads> docker -v
Docker version 27.5.1, build 9f9e405
PS C:\Users\brbayes\Downloads> skopeo -v
skopeo version 1.17.0
PS C:\Users\brbayes\Downloads> skopeo inspect docker://quay.io/libpod/alpine --override-os linux | jq '.Digest,.LayersData[].MIMEType'
"sha256:fa93b01658e3a5a1686dc3ae55f170d8de487006fb53a28efcd12ab0710a2e5f"
"application/vnd.docker.image.rootfs.diff.tar.gzip"
PS C:\Users\brbayes\Downloads> docker pull quay.io/libpod/alpine
Using default tag: latest
latest: Pulling from libpod/alpine
Digest: sha256:fa93b01658e3a5a1686dc3ae55f170d8de487006fb53a28efcd12ab0710a2e5f
Status: Image is up to date for quay.io/libpod/alpine:latest
quay.io/libpod/alpine:latest

What's next:
    View a summary of image vulnerabilities and recommendations → docker scout quickview quay.io/libpod/alpine
PS C:\Users\brbayes\Downloads> docker save -o libpod.tar quay.io/libpod/alpine
PS C:\Users\brbayes\Downloads> skopeo inspect --raw oci-archive:libpod.tar | jq -r .mediaType
application/vnd.docker.distribution.manifest.list.v2+json

@mtrmac
Copy link
Collaborator
mtrmac commented Feb 10, 2025

Thanks.

I’m looking at https://github.com/moby/moby/blob/8ca767963101763af2d8e44ea24ae0756adcfb05/image/tarexport/save.go#L250, that’s clearly not that path.

This is with the containerd backend, isn’t it?

@brbayes-msft
Copy link
Contributor Author

That's correct, this is using the containerd backend both on my local machine, and on the linux hosts.

@mtrmac
Copy link
Collaborator
mtrmac commented Feb 11, 2025

Thanks, reproduced. Fine, let’s do this.

… and it saves the original multi-platform manifest list, but the archive only contains the one pulled architecture. I.e. the image is sparse. That’s going to be fun.

Copy link
Collaborator
@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM. Can you squash this into one commit, and perhaps rebase, please? Thanks!

@mtrmac mtrmac added the kind/feature A request for, or a PR adding, new functionality label Feb 11, 2025
Signed-off-by: Brandyn Bayes <brbayes@microsoft.com>
@brbayes-msft brbayes-msft force-pushed the brbayes/docker-media-types branch from 8e90432 to 5771973 Compare February 11, 2025 23:31
@brbayes-msft
Copy link
Contributor Author

The changes are squashed and rebased.

Copy link
Collaborator
@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@mtrmac mtrmac merged commit 6d26de0 into containers:main Feb 12, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature A request for, or a PR adding, new functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0