google / google/go-containerregistry

question: support for v1layout tarball?

Open
#1,879 3 comments 0 reactions 0 assignees View on GitHub
lifecycle/frozen lifecycle/stale question
Dominant language
Go
Stars
4k
Forks
686
Avg merge
2d 12h
Merged PRs (30d)
26

Description

The [v1/tarball.Write()](https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/tarball#Write) writes it in docker's unique tarball format. Per the summary:

> This package produces tarballs that can consumed via docker load. Note that this is a different format from the [legacy](https://github.com/google/go-containerregistry/blob/v0.19.0/pkg/v1/tarball/pkg/legacy/tarball) tarballs that are produced by docker save, but this package is still able to read the legacy tarballs produced by docker save.

As of docker engine v25, `docker save` actually writes to OCI layout tarball, i.e.:

```bash
$ docker save alpine:3.19 > /tmp/alpine319.tar
$ tar xvf /tmp/alpine319.tar
x blobs/
x blobs/sha256/
x blobs/sha256/a0264d60f80df12bc1e6dd98bae6c43debe6667c0ba482711f0d806493467a46
x blobs/sha256/ace17d5d883e9ea5a21138d0608d60aa2376c68f616c55b0b7e73fba6d8556a3
x blobs/sha256/bca4290a96390d7a6fc6f2f9929370d06f8dfcacba591c76e3d5c5044e7f420c
x blobs/sha256/c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b
x index.json
x manifest.json
x oci-layout
```

That is almost identical to v1 layout, which GGCR supports, with the exception of:

* it is in a tar stream, not an actual layout
* it includes docker's unique `manifest.json`

FWIW, this is identical to the results of using buildkit with `--output type=oci,path=/tmp/foo.tar`

Is there a way to output this tar format? In theory, we could output to a directory using `layout.Write()` and then tar it up, but that is inefficient and could get messed up, and in any case, it all is a tar stream.

Contributor guide

Open the contributing guide

Research direction

Start with pkg/v1/tarball and the v1/tarball.Write entry point, then compare its output with pkg/v1/tarball/pkg/legacy/tarball and layout.Write. Check how Docker v25 and BuildKit structure OCI layout tar streams, including manifest.json; done means the library can produce that tar format without requiring an intermediate directory.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.