Skip to content

Commit

Permalink
media-types: Define '+gzip' structured syntax suffix
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
wking committed Sep 20, 2016
1 parent f4a7ea2 commit c41dfb1
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 11 deletions.
3 changes: 2 additions & 1 deletion config.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ This specification uses the following terms:
<dd>
A layer DiffID is a SHA256 digest over the layer's uncompressed tar archive and serialized in the descriptor digest format, e.g., <code>sha256:a9561eb1b190625c9adb5a9513e72c4dedafc1cb2d4c5236c9a6957ec7dfd5a9</code>.
Layers must be packed and unpacked reproducibly to avoid changing the layer ID, for example by using tar-split to save the tar headers.
NOTE: the DiffID is different than the digest in the manifest list because the manifest digest is taken over the gzipped layer for <code>application/vnd.oci.image.layer.tar+gzip</code> types.
The DiffID is different than the layer digest in the <a href="manifest.md#image-manifest-property-descriptions">manifest's <code>layers</code></a> because the layer digest is taken over the blob regardless of compression, while the DiffID is taken after removing any compression.
For an <code>application/vnd.oci.image.layer.tar+gzip</code> layer, the layer digest is taken over the <code>application/vnd.oci.image.layer.tar+gzip</code> content, while the DiffID is take over the <code>application/vnd.oci.image.layer.tar</code> content.
</dd>
<dt>
Layer ChainID
Expand Down
2 changes: 1 addition & 1 deletion img/media-types.dot
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ digraph G {
manifestList [shape=note, label="Manifest list\n<<optional>>\napplication/vnd.oci.image.manifest.list.v1+json"]
manifest [shape=note, label="Image manifest\napplication/vnd.oci.image.manifest.v1+json"]
config [shape=note, label="Image JSON\napplication/vnd.oci.image.config.v1+json"]
layer [shape=note, label="Layer tar+gzip\napplication/vnd.oci.image.layer.tar+gzip\napplication/vnd.oci.image.layer.nondistributable.tar+gzip"]
layer [shape=note, label="Layer tar archive\napplication/vnd.oci.image.layer.tar\napplication/vnd.oci.image.layer.nondistributable.tar"]
}

manifestList -> manifest [label="1..*"]
Expand Down
8 changes: 4 additions & 4 deletions layer.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ This document will use a concrete example to illustrate how to create and consum

## Distributable Format

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

## Change Types

Expand Down Expand Up @@ -170,7 +170,7 @@ Where the basename name of `./etc/my-app-config` is now prefixed with `.wh.`, an

## Applying

Layer Changesets of [mediatype](./media-types.md) `application/vnd.oci.image.layer.tar+gzip` are applied rather than strictly extracted in normal fashion for tar archives.
Layer Changesets of [mediatype](./media-types.md) `application/vnd.oci.image.layer.tar` are applied rather than strictly extracted in normal fashion for tar archives.

Applying a layer changeset requires consideration for the [whiteout](#whiteouts) files.
In the absence of any [whiteout](#whiteouts) files in a layer changeset, the archive is extracted like a regular tar archive.
Expand Down Expand Up @@ -275,7 +275,7 @@ Any given image is likely to be composed of several of these Image Filesystem Ch
Certain layers, due to legal requirements, may not be regularly distributable.
Typically, such layers are downloaded directly from a distributor but are never uploaded.

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

Expand Down
47 changes: 44 additions & 3 deletions media-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,45 @@ The following media types identify the formats described here and their referenc
- `application/vnd.oci.image.manifest.list.v1+json`: [Manifest list](manifest.md#manifest-list)
- `application/vnd.oci.image.manifest.v1+json`: [Image manifest format](manifest.md#image-manifest)
- `application/vnd.oci.image.config.v1+json`: [Container config JSON](config.md)
- `application/vnd.oci.image.layer.tar+gzip`: ["Layer", as a gzipped tar archive](layer.md)
- `application/vnd.oci.image.layer.nondistributable.tar+gzip`: ["Layer", as a gzipped tar that has distribution restrictions](layer.md#non-distributable-layers)
- `application/vnd.oci.image.layer.tar`: ["Layer", as a tar archive](layer.md)
- `application/vnd.oci.image.layer.nondistributable.tar`: ["Layer", as a tar archive with distribution restrictions](layer.md#non-distributable-layers)

## Suffixes

[RFC 6839][rfc6839] defines several structured syntax suffixes for use with media types.
This section adds additional structured syntax suffixes for use with media types in OCI Image contexts.

### The +gzip Structured Syntax Suffix

[GZIP][rfc1952] is a widely used compression format.
The media type [`application/gzip`][rfc6713] has been registered for such files.
The suffix `+gzip` MAY be used with any media type whose representation follows that established for `application/gzip`.
The media type structured syntax suffix registration form follows:

Name: GZIP file format

`+suffix`: `+gzip`

References: [[GZIP][rfc1952]]

Encoding considerations: GZIP is a binary encoding.

Fragment identifier considerations:

The syntax and semantics of fragment identifiers specified for `+gzip` SHOULD be as specified for `application/gzip`.
(At publication of this document, there is no fragment identification syntax defined for `application/gzip`.)
The syntax and semantics for fragment identifiers for a specific `xxx/yyy+gzip` SHOULD be processed as follows:

* For cases defined in `+gzip`, where the fragment identifier resolves per the `+gzip` rules, then process as specified in `+gzip`.
* For cases defined in `+gzip`, where the fragment identifier does not resolve per the `+gzip` rules, then process as specified in `xxx/yyy+gzip`.
* For cases not defined in `+gzip`, then process as specified in `xxx/yyy+gzip`.

Interoperability considerations: n/a

Security considerations:

See the "Security Considerations" sections of [RFC 1952][rfc1952] and [RFC 6713][rfc6713].
Each individual media type registered with a `+gzip` suffix can have additional security considerations.

## Compatibility Matrix

Expand All @@ -27,7 +64,7 @@ This section shows where the OCI Image Specification is compatible with formats

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

### application/vnd.oci.image.rootfs.tar.gzip
### application/vnd.oci.image.layer.tar

**Interchangeable and fully compatible mime-types**

Expand All @@ -47,3 +84,7 @@ The following figure shows how the above media types reference each other:

[Descriptors](descriptor.md) are used for all references.
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.

[rfc1952]: https://tools.ietf.org/html/rfc1952
[rfc6713]: https://tools.ietf.org/html/rfc6713
[rfc6839]: https://tools.ietf.org/html/rfc6839
4 changes: 2 additions & 2 deletions specs-go/v1/mediatype.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ const (
MediaTypeImageManifestList = "application/vnd.oci.image.manifest.list.v1+json"

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

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

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

0 comments on commit c41dfb1

Please sign in to comment.