| 1 |
# Creating smaller eStargz images |
| 2 |
|
| 3 |
The following flags of `ctr-remote i convert` and `ctr-remote i optimize` allow users optionally creating smaller eStargz images. |
| 4 |
|
| 5 |
- `--estargz-external-toc`: Separate TOC JSON into another image (called "TOC image"). The result eStargz doesn't contain TOC so we can expect a smaller size than normal eStargz. |
| 6 |
|
| 7 |
- `--estargz-min-chunk-size`: The minimal number of bytes of data must be written in one gzip stream. If it's > 0, multiple files and chunks can be written into one gzip stream. Smaller number of gzip header and smaller size of the result blob can be expected. `--estargz-min-chunk-size=0` produces normal eStargz. |
| 8 |
|
| 9 |
## `--estargz-external-toc` usage |
| 10 |
|
| 11 |
convert: |
| 12 |
|
| 13 |
```console |
| 14 |
# ctr-remote i pull ghcr.io/stargz-containers/ubuntu:22.04 |
| 15 |
# ctr-remote i convert --oci --estargz --estargz-external-toc ghcr.io/stargz-containers/ubuntu:22.04 registry2:5000/ubuntu:22.04-ex |
| 16 |
``` |
| 17 |
|
| 18 |
Layers in eStargz (`registry2:5000/ubuntu:22.04-ex`) don't contain TOC JSON. |
| 19 |
TOC image (`registry2:5000/ubuntu:22.04-ex-esgztoc`) contains TOC of all layers of the eStargz image. |
| 20 |
Suffix `-esgztoc` is automatically added to the image name by `ctr-remote`. |
| 21 |
|
| 22 |
Then push eStargz(`registry2:5000/ubuntu:22.04-ex`) and TOC image(`registry2:5000/ubuntu:22.04-ex-esgztoc`) to the same registry: |
| 23 |
|
| 24 |
```console |
| 25 |
# ctr-remote i push --plain-http registry2:5000/ubuntu:22.04-ex |
| 26 |
# ctr-remote i push --plain-http registry2:5000/ubuntu:22.04-ex-esgztoc |
| 27 |
``` |
| 28 |
|
| 29 |
Pull it lazily: |
| 30 |
|
| 31 |
```console |
| 32 |
# ctr-remote i rpull --plain-http registry2:5000/ubuntu:22.04-ex |
| 33 |
fetching sha256:14fb0ea2... application/vnd.oci.image.index.v1+json |
| 34 |
fetching sha256:24471b45... application/vnd.oci.image.manifest.v1+json |
| 35 |
fetching sha256:d2e4737e... application/vnd.oci.image.config.v1+json |
| 36 |
# mount | grep "stargz on" |
| 37 |
stargz on /var/lib/containerd-stargz-grpc/snapshotter/snapshots/1/fs type fuse.rawBridge (rw,nodev,relatime,user_id=0,group_id=0,allow_other) |
| 38 |
``` |
| 39 |
|
| 40 |
Stargz Snapshotter automatically refers to the TOC image on the same registry. |
| 41 |
|
| 42 |
### optional `--estargz-keep-diff-id` flag for conversion without changing layer diffID |
| 43 |
|
| 44 |
`ctr-remote i convert` supports optional flag `--estargz-keep-diff-id` specified with `--estargz-external-toc`. |
| 45 |
This converts an image to eStargz without changing the diffID (uncompressed digest) so even eStargz-agnostic gzip decompressor (e.g. gunzip) can restore the original tar blob. |
| 46 |
|
| 47 |
```console |
| 48 |
# ctr-remote i pull ghcr.io/stargz-containers/ubuntu:22.04 |
| 49 |
# ctr-remote i convert --oci --estargz --estargz-external-toc --estargz-keep-diff-id ghcr.io/stargz-containers/ubuntu:22.04 registry2:5000/ubuntu:22.04-ex-keepdiff |
| 50 |
# ctr-remote i push --plain-http registry2:5000/ubuntu:22.04-ex-keepdiff |
| 51 |
# ctr-remote i push --plain-http registry2:5000/ubuntu:22.04-ex-keepdiff-esgztoc |
| 52 |
# crane --insecure blob registry2:5000/ubuntu:22.04-ex-keepdiff@sha256:2dc39ba059dcd42ade30aae30147b5692777ba9ff0779a62ad93a74de02e3e1f | jq -r '.rootfs.diff_ids[]' |
| 53 |
sha256:7f5cbd8cc787c8d628630756bcc7240e6c96b876c2882e6fc980a8b60cdfa274 |
| 54 |
# crane blob ghcr.io/stargz-containers/ubuntu:22.04@sha256:2dc39ba059dcd42ade30aae30147b5692777ba9ff0779a62ad93a74de02e3e1f | jq -r '.rootfs.diff_ids[]' |
| 55 |
sha256:7f5cbd8cc787c8d628630756bcc7240e6c96b876c2882e6fc980a8b60cdfa274 |
| 56 |
``` |
| 57 |
|
| 58 |
## `--estargz-min-chunk-size` usage |
| 59 |
|
| 60 |
conversion: |
| 61 |
|
| 62 |
```console |
| 63 |
# ctr-remote i pull ghcr.io/stargz-containers/ubuntu:22.04 |
| 64 |
# ctr-remote i convert --oci --estargz --estargz-min-chunk-size=50000 ghcr.io/stargz-containers/ubuntu:22.04 registry2:5000/ubuntu:22.04-chunk50000 |
| 65 |
# ctr-remote i push --plain-http registry2:5000/ubuntu:22.04-chunk50000 |
| 66 |
``` |
| 67 |
|
| 68 |
Pull it lazily: |
| 69 |
|
| 70 |
```console |
| 71 |
# ctr-remote i rpull --plain-http registry2:5000/ubuntu:22.04-chunk50000 |
| 72 |
fetching sha256:5d1409a2... application/vnd.oci.image.index.v1+json |
| 73 |
fetching sha256:859e2b50... application/vnd.oci.image.manifest.v1+json |
| 74 |
fetching sha256:c07a44b9... application/vnd.oci.image.config.v1+json |
| 75 |
# mount | grep "stargz on" |
| 76 |
stargz on /var/lib/containerd-stargz-grpc/snapshotter/snapshots/1/fs type fuse.rawBridge (rw,nodev,relatime,user_id=0,group_id=0,allow_other) |
| 77 |
``` |
| 78 |
|
| 79 |
> NOTE: This flag creates an eStargz image with newly-added `innerOffset` funtionality of eStargz. Stargz Snapshotter < v0.13.0 cannot perform lazy pulling for the images created with this flag. |