Skip to content

Commit 0b5a64a

Browse files
authored
Merge pull request #4543 from escapefreeg/main
add support for the new --estargz-gzip-helper option in stargz-snapshotter
2 parents 0da9a69 + 35cc34f commit 0b5a64a

File tree

6 files changed

+83
-50
lines changed

6 files changed

+83
-50
lines changed

cmd/nerdctl/image/image_convert.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func convertCommand() *cobra.Command {
6161
cmd.Flags().Int("estargz-min-chunk-size", 0, "The minimal number of bytes of data must be written in one gzip stream. (requires stargz-snapshotter >= v0.13.0)")
6262
cmd.Flags().Bool("estargz-external-toc", false, "Separate TOC JSON into another image (called \"TOC image\"). The name of TOC image is the original + \"-esgztoc\" suffix. Both eStargz and the TOC image should be pushed to the same registry. (requires stargz-snapshotter >= v0.13.0) (EXPERIMENTAL)")
6363
cmd.Flags().Bool("estargz-keep-diff-id", false, "Convert to esgz without changing diffID (cannot be used in conjunction with '--estargz-record-in'. must be specified with '--estargz-external-toc')")
64+
cmd.Flags().String("estargz-gzip-helper", "", "Helper command for decompressing layers compressed with gzip. Options: pigz, igzip, or gzip.")
6465
// #endregion
6566

6667
// #region zstd flags
@@ -149,6 +150,10 @@ func convertOptions(cmd *cobra.Command) (types.ImageConvertOptions, error) {
149150
if err != nil {
150151
return types.ImageConvertOptions{}, err
151152
}
153+
estargzGzipHelper, err := cmd.Flags().GetString("estargz-gzip-helper")
154+
if err != nil {
155+
return types.ImageConvertOptions{}, err
156+
}
152157
// #endregion
153158

154159
// #region zstd flags
@@ -275,6 +280,7 @@ func convertOptions(cmd *cobra.Command) (types.ImageConvertOptions, error) {
275280
EstargzMinChunkSize: estargzMinChunkSize,
276281
EstargzExternalToc: estargzExternalTOC,
277282
EstargzKeepDiffID: estargzKeepDiffID,
283+
EstargzGzipHelper: estargzGzipHelper,
278284
},
279285
ZstdOptions: types.ZstdOptions{
280286
Zstd: zstd,

docs/stargz.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,20 @@ Stargz Snapshotter is not needed for building stargz images.
9292

9393
## Tips for image conversion
9494

95-
### Tips 1: Creating smaller eStargz images
95+
### Tips 1: Using gzip helper to speed up image conversion
96+
97+
When converting a traditional overlayfs image encoded as tar.gz to an estargz format image, nerdctl supports specifying an additional command‑line decompression tool to speed up the conversion process. You can set `--estargz-gzip-helper` to choose different CLI gzip tools. Even using the gzip command corresponding to the Go gzip library can achieve approximately 32% speed improvement. For more details, see: [Using decompression commands to improve the layer decompression speed of gzip-formatted images](https://github.com/containerd/stargz-snapshotter/pull/2117). Currently, `--estargz-gzip-helper` supports `pigz`, `igzip`, and `gzip`. The recommended order is `pigz` > `igzip` > `gzip`.
98+
99+
```console
100+
# nerdctl image convert --oci --estargz --estargz-gzip-helper pigz ghcr.io/stargz-containers/ubuntu:22.04 ghcr.io/stargz-containers/ubuntu:22.04-esgz
101+
sha256:aa6543b9885867b8b485925b6ec69d8e018e8fce40835ea6359cbb573683a014
102+
# nerdctl image ls
103+
REPOSITORY TAG IMAGE ID CREATED PLATFORM SIZE BLOB SIZE
104+
ghcr.io/stargz-containers/ubuntu 22.04-esgz aa6543b98858 About a minute ago linux/amd64 0B 32.43MB
105+
ghcr.io/stargz-containers/ubuntu 22.04 20fa2d7bb4de 2 minutes ago linux/amd64 87.47MB 30.43MB
106+
```
107+
108+
### Tips 2: Creating smaller eStargz images
96109

97110
`nerdctl image convert` allows the following flags for optionally creating a smaller eStargz image.
98111
The result image requires stargz-snapshotter >= v0.13.0 for lazy pulling.
@@ -167,7 +180,7 @@ sha256:7f5cbd8cc787c8d628630756bcc7240e6c96b876c2882e6fc980a8b60cdfa274
167180
sha256:7f5cbd8cc787c8d628630756bcc7240e6c96b876c2882e6fc980a8b60cdfa274
168181
```
169182

170-
### Tips 2: Using zstd instead of gzip (a.k.a. zstd:chunked)
183+
### Tips 3: Using zstd instead of gzip (a.k.a. zstd:chunked)
171184

172185
You can use zstd compression with lazy pulling support (a.k.a zstd:chunked) instead of gzip.
173186

go.mod

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ require (
2222
github.com/containerd/nerdctl/mod/tigron v0.0.0
2323
github.com/containerd/nydus-snapshotter v0.15.5 //gomodjail:unconfined
2424
github.com/containerd/platforms v1.0.0-rc.1 //gomodjail:unconfined
25-
github.com/containerd/stargz-snapshotter v0.17.0 //gomodjail:unconfined
26-
github.com/containerd/stargz-snapshotter/estargz v0.17.0 //gomodjail:unconfined
27-
github.com/containerd/stargz-snapshotter/ipfs v0.17.0 //gomodjail:unconfined
25+
github.com/containerd/stargz-snapshotter v0.18.0 //gomodjail:unconfined
26+
github.com/containerd/stargz-snapshotter/estargz v0.18.0 //gomodjail:unconfined
27+
github.com/containerd/stargz-snapshotter/ipfs v0.18.0 //gomodjail:unconfined
2828
github.com/containerd/typeurl/v2 v2.2.3
2929
github.com/containernetworking/cni v1.3.0 //gomodjail:unconfined
3030
github.com/containernetworking/plugins v1.8.0 //gomodjail:unconfined
@@ -85,7 +85,7 @@ require (
8585
github.com/djherbis/times v1.6.0 // indirect
8686
github.com/docker/docker-credential-helpers v0.8.2 // indirect
8787
github.com/felixge/httpsnoop v1.0.4 // indirect
88-
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
88+
github.com/go-jose/go-jose/v4 v4.1.2 // indirect
8989
github.com/go-logr/logr v1.4.3 // indirect
9090
github.com/go-logr/stdr v1.2.2 // indirect
9191
github.com/godbus/dbus/v5 v5.1.0 // indirect
@@ -108,7 +108,7 @@ require (
108108
github.com/mr-tron/base58 v1.2.0 // indirect
109109
github.com/multiformats/go-base32 v0.1.0 // indirect
110110
github.com/multiformats/go-base36 v0.2.0 // indirect
111-
github.com/multiformats/go-multiaddr v0.16.0 // indirect
111+
github.com/multiformats/go-multiaddr v0.16.1 // indirect
112112
github.com/multiformats/go-multibase v0.2.0 // indirect
113113
github.com/multiformats/go-multihash v0.2.3 // indirect
114114
github.com/multiformats/go-varint v0.0.7 // indirect
@@ -127,24 +127,25 @@ require (
127127
//gomodjail:unconfined
128128
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
129129
github.com/tinylib/msgp v1.3.0 // indirect
130-
github.com/vbatts/tar-split v0.12.1 // indirect
130+
github.com/vbatts/tar-split v0.12.2 // indirect
131131
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
132132
go.opencensus.io v0.24.0 // indirect
133133
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
134134
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 // indirect
135-
go.opentelemetry.io/otel v1.35.0 // indirect
136-
go.opentelemetry.io/otel/metric v1.35.0 // indirect
137-
go.opentelemetry.io/otel/trace v1.35.0 // indirect
135+
go.opentelemetry.io/otel v1.37.0 // indirect
136+
go.opentelemetry.io/otel/metric v1.37.0 // indirect
137+
go.opentelemetry.io/otel/trace v1.37.0 // indirect
138+
go.yaml.in/yaml/v2 v2.4.2 // indirect
138139
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
139140
golang.org/x/mod v0.28.0 // indirect
140-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 // indirect
141+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect
141142
//gomodjail:unconfined
142-
google.golang.org/grpc v1.73.0 // indirect
143+
google.golang.org/grpc v1.76.0 // indirect
143144
//gomodjail:unconfined
144-
google.golang.org/protobuf v1.36.7 // indirect
145+
google.golang.org/protobuf v1.36.8 // indirect
145146
gopkg.in/yaml.v3 v3.0.1 // indirect
146147
lukechampine.com/blake3 v1.3.0 // indirect
147-
sigs.k8s.io/yaml v1.4.0 // indirect
148+
sigs.k8s.io/yaml v1.6.0 // indirect
148149
tags.cncf.io/container-device-interface/specs-go v1.0.0 // indirect
149150
)
150151

0 commit comments

Comments
 (0)