Description
What is the problem you're trying to solve
Motivation
Currently, nerdctl commit
always creates images using Docker Schema2 media types (application/vnd.docker.container.image.v1+json
, application/vnd.docker.distribution.manifest.v2+json
). While this provides excellent Docker compatibility, it creates several critical issues:
Problem 1: Mixed Media Type Images
When committing containers that were created from OCI-format images, the current implementation creates mixed-format images with inconsistent media types:
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"schemaVersion": 2,
"config": {
"mediaType": "application/vnd.docker.container.image.v1+json",
"digest": "sha256:1228f0866ba907da59e933fb318796968b4de520227a3b3875b94a94cb2bd3ec",
"size": 7763
},
"layers": [
{
"mediaType": "application/vnd.oci.image.layer.v1.tar+gzip",
"digest": "sha256:9a8ece1256563321005c05a5e56e74f9b6b5033fd3b278156d5af768f2343b72",
"size": 31413787
},
// ... more OCI layers from base image
{
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
"digest": "sha256:a483e3847f6fe662c0ae09609ed60ffad7902206bc0809b19bda895899043ba9",
"size": 155
}
]
}
Issues with this approach:
- Manifest and config use Docker Schema2 media types
- Existing layers from the base image retain OCI media types
- New layer from commit uses Docker media type
- Result: Inconsistent, mixed-format image
Problem 2: Tool Compatibility Issues
Mixed-format images cause failures with various container tools:
# skopeo fails to inspect mixed-format images
$ skopeo inspect docker://registry.domain.local/library/app1:after-commit
FATA[0000] Error parsing manifest for image: unsupported docker v2s2 media type: "application/vnd.oci.image.layer.v1.tar+gzip"
Other tools may also fail or behave unexpectedly when encountering these hybrid images.
Problem 3: Lack of Format Control
Users working in OCI-native environments have no way to:
- Maintain OCI format consistency when committing OCI-based containers
- Choose their preferred image format for committed images
- Ensure compatibility with their toolchain and registry requirements
Describe the solution you'd like
Solution: Add an option to nerdctl commit command for media type selection
This enhancement would:
- Eliminate mixed-format images: Ensure consistent media types throughout the image
- Provide format control: Users can choose the appropriate format for their workflow
- Maintain tool compatibility: Avoid failures with tools like skopeo.
- Support OCI-native workflows: Enable full OCI format support
- Preserve backward compatibility: Docker format remains default
Proposed Solution
Add a --format
flag to the nerdctl commit
command with two supported values:
docker
(default): Use Docker Schema2 media typesoci
: Use OCI image format media types
Command Usage
# Default behavior (Docker Schema2 format)
nerdctl commit container-name new-image:tag
# Explicitly specify Docker format
nerdctl commit --format docker container-name new-image:tag
# Use OCI format
nerdctl commit --format oci container-name new-image:tag
Media Type Mapping
Format | Config Media Type | Manifest Media Type | Layer Media Type |
---|---|---|---|
docker |
application/vnd.docker.container.image.v1+json |
application/vnd.docker.distribution.manifest.v2+json |
application/vnd.docker.image.rootfs.diff.tar.gzip |
oci |
application/vnd.oci.image.config.v1+json |
application/vnd.oci.image.manifest.v1+json |
application/vnd.oci.image.layer.v1.tar+gzip |
Additional context
No response