Skip to content

Commit de7026a

Browse files
committed
media-types: Define '+gzip' structured syntax suffix
Leaning heavily on the existing entries in RFC 6839. The suffix makes it easy to clarify DiffIDs without requiring a particular layer media type. It also allows you to create image-layout instances where the layers are stored uncompressed, which may be useful for cases such as: * Binary diffing between layer blobs for cheaper updates of large layers [1]. * Compressing an image-layout tarball for a smaller smaller overall tarball (by avoiding the unnecessary fragmentation of compressing the individual blob entries). [1]: http://ircbot.wl.linuxfoundation.org/eavesdrop/%23opencontainers/%23opencontainers.2016-08-16.log.html#t2016-08-16T23:35:43 Signed-off-by: W. Trevor King <[email protected]>
1 parent ed9ffce commit de7026a

File tree

6 files changed

+64
-16
lines changed

6 files changed

+64
-16
lines changed

config.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ Changing it means creating a new derived image, instead of changing the existing
2828
A layer DiffID is a SHA256 digest over the layer's uncompressed tar archive and serialized in the descriptor digest format, e.g., `sha256:a9561eb1b190625c9adb5a9513e72c4dedafc1cb2d4c5236c9a6957ec7dfd5a9`.
2929
Layers must be packed and unpacked reproducibly to avoid changing the layer DiffID, for example by using tar-split to save the tar headers.
3030

31-
NOTE: the DiffID is different than the digest in the manifest list because the manifest digest is taken over the gzipped layer for `application/vnd.oci.image.layer.v1.tar+gzip` types.
31+
The difference between DiffIDs and the layer digests in the [manifest's `layers`](manifest.md#image-manifest-property-descriptions) is that the layer digest is taken over the blob regardless of compression, while the DiffID is taken after removing any compression.
32+
For an `application/vnd.oci.image.layer.tar+gzip` layer, the layer digest is taken over the `application/vnd.oci.image.layer.tar+gzip` content, while the DiffID is take over the `application/vnd.oci.image.layer.tar` content.
3233

3334
### Layer ChainID
3435

img/media-types.dot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ digraph G {
33
manifestList [shape=note, label="Manifest list\n<<optional>>\napplication/vnd.oci.image.manifest.list.v1+json"]
44
manifest [shape=note, label="Image manifest\napplication/vnd.oci.image.manifest.v1+json"]
55
config [shape=note, label="Image JSON\napplication/vnd.oci.image.config.v1+json"]
6-
layer [shape=note, label="Layer tar+gzip\napplication/vnd.oci.image.layer.v1.tar+gzip\napplication/vnd.oci.image.layer.nondistributable.v1.tar+gzip"]
6+
layer [shape=note, label="Layer tar archive\napplication/vnd.oci.image.layer.v1.tar\napplication/vnd.oci.image.layer.nondistributable.v1.tar"]
77
}
88

99
manifestList -> manifest [label="1..*"]

layer.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ This document describes how to serialize a filesystem and filesystem changes lik
44
One or more layers are applied on top of each other to create a complete filesystem.
55
This document will use a concrete example to illustrate how to create and consume these filesystem layers.
66

7-
This section defines the `application/vnd.oci.image.layer.v1.tar+gzip` and `application/vnd.oci.image.layer.nondistributable.v1.tar+gzip` [media types](media-types.md).
7+
This section defines the `application/vnd.oci.image.layer.v1.tar` and `application/vnd.oci.image.layer.nondistributable.v1.tar` [media types](media-types.md).
88

99
## Distributable Format
1010

11-
Layer Changesets for the [mediatype](./media-types.md) `application/vnd.oci.image.layer.v1.tar+gzip` MUST be packaged in a [tar archive][tar-archive] compressed with [gzip][gzip].
12-
Layer Changesets for the [mediatype](./media-types.md) `application/vnd.oci.image.layer.v1.tar+gzip` MUST NOT include duplicate entries for file paths in the resulting [tar archive][tar-archive].
11+
Layer Changesets for the [media type](./media-types.md) `application/vnd.oci.image.layer.v1.tar` MUST be packaged in [tar archive][tar-archive].
12+
Layer Changesets for the [media type](./media-types.md) `application/vnd.oci.image.layer.v1.tar` MUST NOT include duplicate entries for file paths in the resulting [tar archive][tar-archive].
1313

1414
## Change Types
1515

@@ -208,7 +208,7 @@ To signify that the resource `./etc/my-app-config` MUST be removed when the chan
208208

209209
## Applying Changesets
210210

211-
Layer Changesets of [mediatype](./media-types.md) `application/vnd.oci.image.layer.v1.tar+gzip` are _applied_, rather than simply extracted as tar archives.
211+
Layer Changesets of [media type](./media-types.md) `application/vnd.oci.image.layer.v1.tar` are _applied_, rather than simply extracted as tar archives.
212212

213213
Applying a layer changeset requires special consideration for the [whiteout](#whiteouts) files.
214214

@@ -311,11 +311,10 @@ Any given image is likely to be composed of several of these Image Filesystem Ch
311311
Certain layers, due to legal requirements, may not be regularly distributable.
312312
Typically, such layers are downloaded directly from a distributor but are never uploaded.
313313

314-
Layers that have these restrictions SHOULD be tagged with an alternative mediatype of `application/vnd.oci.image.layer.nondistributable.v1.tar+gzip`.
314+
Layers that have these restrictions SHOULD be tagged with an alternative media type of `application/vnd.oci.image.layer.nondistributable.v1.tar`.
315315
[Descriptors](descriptor.md) referencing these layers MAY include `urls` for downloading these layers.
316316
It is implementation-defined whether or not implementations upload layers tagged with this media type.
317317

318318
[libarchive-tar]: https://github.com/libarchive/libarchive/wiki/ManPageTar5#POSIX_ustar_Archives
319319
[gnu-tar-standard]: http://www.gnu.org/software/tar/manual/html_node/Standard.html
320320
[tar-archive]: https://en.wikipedia.org/wiki/Tar_(computing)
321-
[gzip]: http://www.zlib.org/rfc-gzip.html

manifest.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ Unlike the [Manifest List](manifest-list.md), which contains information about a
5454
This [descriptor property](descriptor.md#properties) has additional restrictions for `layers[]`.
5555
Implementations MUST support at least the following media types:
5656

57-
- [`application/vnd.oci.image.layer.v1.tar+gzip`](layer.md)
58-
- [`application/vnd.oci.image.layer.nondistributable.v1.tar+gzip`](layer.md#non-distributable-layers)
57+
- [`application/vnd.oci.image.layer.v1.tar`](layer.md)
58+
- [`application/vnd.oci.image.layer.nondistributable.v1.tar`](layer.md#non-distributable-layers)
5959

6060
Manifests concerned with portability SHOULD use one of the above media types.
6161

62+
Entries in this field will frequently use the [`+gzip` structured syntax suffix](media-types.md#the-gzip-structured-syntax-suffix).
63+
6264
- **`annotations`** *string-string map*
6365

6466
This OPTIONAL property contains arbitrary metadata for the image manifest.

media-types.md

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,48 @@ The following media types identify the formats described here and their referenc
66
- `application/vnd.oci.image.manifest.list.v1+json`: [Manifest list](manifest-list.md#manifest-list)
77
- `application/vnd.oci.image.manifest.v1+json`: [Image manifest](manifest.md#image-manifest)
88
- `application/vnd.oci.image.config.v1+json`: [Image config](config.md)
9-
- `application/vnd.oci.image.layer.v1.tar+gzip`: ["Layer", as a gzipped tar archive](layer.md)
10-
- `application/vnd.oci.image.layer.nondistributable.v1.tar+gzip`: ["Layer", as a gzipped tar archive with distribution restrictions](layer.md#non-distributable-layers)
9+
- `application/vnd.oci.image.layer.v1.tar`: ["Layer", as a tar archive](layer.md)
10+
- `application/vnd.oci.image.layer.nondistributable.v1.tar`: ["Layer", as a tar archive with distribution restrictions](layer.md#non-distributable-layers)
11+
12+
## Suffixes
13+
14+
[RFC 6839][rfc6839] defines several structured syntax suffixes for use with media types.
15+
This section adds additional structured syntax suffixes for use with media types in OCI Image contexts.
16+
17+
### The +gzip Structured Syntax Suffix
18+
19+
[GZIP][rfc1952] is a widely used compression format.
20+
The media type [`application/gzip`][rfc6713] has been registered for such files.
21+
The suffix `+gzip` MAY be used with any media type whose representation follows that established for `application/gzip`.
22+
The media type structured syntax suffix registration form follows:
23+
24+
Name: GZIP file format
25+
26+
`+suffix`: `+gzip`
27+
28+
References: [[GZIP][rfc1952]]
29+
30+
Encoding considerations: GZIP is a binary encoding.
31+
32+
Fragment identifier considerations:
33+
34+
The syntax and semantics of fragment identifiers specified for `+gzip` SHOULD be as specified for `application/gzip`.
35+
(At publication of this document, there is no fragment identification syntax defined for `application/gzip`.)
36+
The syntax and semantics for fragment identifiers for a specific `xxx/yyy+gzip` SHOULD be processed as follows:
37+
38+
* For cases defined in `+gzip`, where the fragment identifier resolves per the `+gzip` rules, then process as specified in `+gzip`.
39+
* For cases defined in `+gzip`, where the fragment identifier does not resolve per the `+gzip` rules, then process as specified in `xxx/yyy+gzip`.
40+
* For cases not defined in `+gzip`, then process as specified in `xxx/yyy+gzip`.
41+
42+
Interoperability considerations: n/a
43+
44+
Security considerations:
45+
46+
See the "Security Considerations" sections of [RFC 1952][rfc1952] and [RFC 6713][rfc6713].
47+
Each individual media type registered with a `+gzip` suffix can have additional security considerations.
48+
49+
Implementations MUST support the `+gzip` suffix for all [OCI Image Media Types](#oci-image-media-types).
50+
For example, they MUST support `application/vnd.oci.image.layer.v1.tar+gzip` and `application/vnd.oci.image.layer.nondistributable.v1.tar+gzip` for [manifest `layers`](manifest.md#image-manifest-property-descriptions) and `application/vnd.oci.image.manifest.v1+json+gzip` for [manifest list `manifests`](manifest-list.md#manifest-list-property-descriptions).
1151

1252
## Media Type Conflicts
1353

@@ -41,11 +81,13 @@ This section shows where the OCI Image Specification is compatible with formats
4181

4282
- [application/vnd.docker.distribution.manifest.v2+json](https://github.com/docker/distribution/blob/master/docs/spec/manifest-v2-2.md#image-manifest-field-descriptions)
4383

44-
### application/vnd.oci.image.rootfs.tar.gzip
84+
### application/vnd.oci.image.layer.v1.tar
4585

4686
**Interchangeable and fully compatible mime-types**
4787

48-
- [application/vnd.docker.image.rootfs.diff.tar.gzip](https://github.com/docker/docker/blob/master/image/spec/v1.md#creating-an-image-filesystem-changeset)
88+
- With `+gzip`
89+
90+
- [application/vnd.docker.image.rootfs.diff.tar.gzip](https://github.com/docker/docker/blob/master/image/spec/v1.md#creating-an-image-filesystem-changeset)
4991

5092
### application/vnd.oci.image.config.v1+json
5193

@@ -61,3 +103,7 @@ The following figure shows how the above media types reference each other:
61103

62104
[Descriptors](descriptor.md) are used for all references.
63105
The manifest list being a "fat manifest" references one or more image manifests per target platform. An image manifest references exactly one target configuration and possibly many layers.
106+
107+
[rfc1952]: https://tools.ietf.org/html/rfc1952
108+
[rfc6713]: https://tools.ietf.org/html/rfc6713
109+
[rfc6839]: https://tools.ietf.org/html/rfc6839

specs-go/v1/mediatype.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ const (
2525
MediaTypeImageManifestList = "application/vnd.oci.image.manifest.list.v1+json"
2626

2727
// MediaTypeImageLayer is the media type used for layers referenced by the manifest.
28-
MediaTypeImageLayer = "application/vnd.oci.image.layer.v1.tar+gzip"
28+
MediaTypeImageLayer = "application/vnd.oci.image.layer.v1.tar"
2929

3030
// MediaTypeImageLayerNonDistributable is the media type for layers referenced by
3131
// the manifest but with distribution restrictions.
32-
MediaTypeImageLayerNonDistributable = "application/vnd.oci.image.layer.nondistributable.v1.tar+gzip"
32+
MediaTypeImageLayerNonDistributable = "application/vnd.oci.image.layer.nondistributable.v1.tar"
3333

3434
// MediaTypeImageConfig specifies the media type for the image configuration.
3535
MediaTypeImageConfig = "application/vnd.oci.image.config.v1+json"

0 commit comments

Comments
 (0)