You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Lazy pulling stargz/eStargz base images (Experimental)
2
2
3
-
This document describes the configuration that allows buildkit to lazily pull [stargz](https://github.com/google/crfs/blob/master/README.md#introducing-stargz)/[eStargz](https://github.com/containerd/stargz-snapshotter/blob/master/docs/stargz-estargz.md)-formatted images from registries and how to obtain stargz/eStargz images.
3
+
This document describes the configuration that allows buildkit to lazily pull [stargz](https://github.com/google/crfs/blob/master/README.md#introducing-stargz)/[eStargz](https://github.com/containerd/stargz-snapshotter/blob/main/docs/estargz.md)-formatted images from registries and how to obtain stargz/eStargz images.
4
4
5
5
By default, buildkit doesn't pull images until they are strictly needed.
6
6
For example, during a build, buildkit doesn't pull the base image until it runs commands on it (e.g. `RUN` Dockerfile instruction) or until it exports stages as tarballs, etc.
@@ -12,28 +12,41 @@ This document describes the configuration and usage of this feature.
12
12
13
13
For more details about stargz/eStargz image format, please see also [Stargz and eStargz image formats](#stargz-and-estargz-image-formats) section.
14
14
15
-
## Known limitations
16
-
17
-
- If you are using containerd worker, stargz snapshotter (`containerd-stargz-grpc`) needs to be run and configured separately.
18
-
- Rootless execution is currently unsupported.
19
-
20
15
## Enabling lazy pulling of stargz/eStargz images
21
16
22
17
Buildkit supports two ways to enable lazy pulling of stargz/eStargz images.
23
18
24
19
### Using builtin support (recommended)
25
20
21
+
- Requirements
22
+
- Rootless execution requires kernel >= 5.11 or Ubuntu kernel. BuildKit >= v0.11 is recommended.
23
+
26
24
OCI worker has builtin support for stargz/eStargz.
27
25
You can enable this feature by running `buildkitd` with an option `--oci-worker-snapshotter=stargz`.
28
26
29
27
```
30
28
buildkitd --oci-worker-snapshotter=stargz
31
29
```
32
30
33
-
This is the easiest way to use this lazy pull feature on buildkit.
34
-
Currently, this configuration is unsupported for containerd worker.
31
+
This is the easiest way to use this lazy pulling feature on buildkit.
35
32
36
-
#### Example of building an image with lazy pull
33
+
#### Builtin stargz snapshotter with rootless
34
+
35
+
To run it by non-root user, you can use [RootlessKit](https://github.com/rootless-containers/rootlesskit/).
> NOTE1: For details about rootless configuration, see [`/docs/rootless.md`](./rootless.md).
46
+
47
+
> NOTE2: If buildkitd can't create directory or socket under `/run`, check if `$XDG_RUNTIME_DIR` is set correctly (e.g. typically `/run/user/$UID`)
48
+
49
+
#### Example of building an image with lazy pulling
37
50
38
51
Once `buildkitd` starts with the above configuration, stargz/eStargz images can be lazily pulled.
39
52
For example, we build the following golang binary with buildkit.
@@ -83,24 +96,16 @@ However if the destination is a registry and the target repository already conta
83
96
84
97
### Using proxy (standalone) snapshotter
85
98
86
-
This is another way to enable stargz-based lazy pull.
87
-
[Stargz Snapshotter (`containerd-stargz-grpc`)](https://github.com/containerd/stargz-snapshotter) needs to be installed.
88
-
Note that buildkit's registry configuration doesn't propagate to stargz snapshotter so it needs to be configured separately when you use private/mirror repositories.
99
+
This is another way to enable stargz-based lazy pulling.
100
+
This configuration is for users of containerd worker.
89
101
90
-
This configuration is for users of containerd worker and ones trying other versions of stargz snapshotter than built into OCI worker.
102
+
- Requirements
103
+
-[Stargz Snapshotter (`containerd-stargz-grpc`)](https://github.com/containerd/stargz-snapshotter) needs to be installed. stargz-snapshotter >= v0.13 is recommended.
104
+
- Rootless execution requires kernel >= 5.11 or Ubuntu kernel. BuildKit >= v0.11 is recommended.
91
105
92
-
#### With OCI worker
93
-
94
-
Spawn `containerd-stargz-grpc` as a separated process.
95
-
Then run `buildkitd` with an option `--oci-worker-proxy-snapshotter-path=/run/containerd-stargz-grpc/containerd-stargz-grpc.sock` which makes it recognize this snapshotter via the socket.
> NOTE: BuildKit's registry configuration isn't propagated to the proxy stargz snapshotter so it needs to be configured separately when you use private/mirror registries. If you use OCI worker + builtin stargz snapshotter, the separated configurations isn't needed.
102
107
103
-
#### With containerd worker
108
+
#### Proxy snapshotter with containerd worker
104
109
105
110
Configure containerd's config.toml (default = `/etc/containerd/config.toml`) to make it recognize stargz snapshotter as a [proxy snapshotter](https://github.com/containerd/containerd/blob/master/PLUGINS.md#proxy-plugins).
#### Registry-related configurations for proxy (standalone) stargz snapshotter
205
+
206
+
> NOTE: You don't need this configuration if you use OCI worker + builtin stargz snapshotter
123
207
124
208
When you use standalone stargz snapshotter, registry configuration needs to be done for the stargz snapshotter process, separately.
125
209
Create a configuration toml file which contains the registry configuration for stargz snapshotter (e.g. `/etc/containerd-stargz-grpc/config.toml`).
126
-
The configuration format [**differs** from buildkit](https://github.com/containerd/stargz-snapshotter/blob/master/cmd/containerd-stargz-grpc/config.go).
210
+
The configuration format [differs from buildkit](https://github.com/containerd/stargz-snapshotter/blob/master/cmd/containerd-stargz-grpc/config.go).
127
211
For more information about this format, please see also [docs in the repository](https://github.com/containerd/stargz-snapshotter/blob/master/docs/overview.md#registry-related-configuration).
[Stargz](https://github.com/google/crfs/blob/master/README.md#introducing-stargz) and [eStargz](https://github.com/containerd/stargz-snapshotter/blob/master/docs/stargz-estargz.md) are OCI/Docker-compatible image formats that can be lazily pulled from standard registries (e.g. Docker Hub, GitHub Container Registry, etc).
226
+
[Stargz](https://github.com/google/crfs/blob/master/README.md#introducing-stargz) and [eStargz](https://github.com/containerd/stargz-snapshotter/blob/main/docs/estargz.md) are OCI/Docker-compatible image formats that can be lazily pulled from standard registries (e.g. Docker Hub, GitHub Container Registry, etc).
143
227
Because they are backwards-compatible to OCI/Docker images, they can run on standard runtimes (e.g. Docker, containerd, etc.).
144
228
Stargz is proposed by [Google CRFS project](https://github.com/google/crfs).
145
229
eStargz is an extended format of stargz by [Stargz Snapshotter](https://github.com/containerd/stargz-snapshotter).
146
-
It comes with [additional features](https://github.com/containerd/stargz-snapshotter/blob/master/docs/stargz-estargz.md#estargz-archive-format) including chunk verification and prefetch for avoiding the overhead of on-demand fetching.
147
-
For more details about lazy pull with stargz/eStargz images, please refer to the docs on these repositories.
230
+
It comes with [additional features](https://github.com/containerd/stargz-snapshotter/blob/main/docs/estargz.md) including chunk verification and prefetch for avoiding the overhead of on-demand fetching.
231
+
For more details about lazy pulling with stargz/eStargz images, please refer to the docs on these repositories.
148
232
149
233
## Creating stargz/eStargz images
150
234
151
235
### Building eStargz image with BuildKit
152
236
153
237
BuildKit supports creating eStargz as one of the compression types.
238
+
239
+
:information_source: Creating eStargz image does NOT require [stargz-snapshotter setup](#enabling-lazy-pulling-of-stargzeStargz-images).
240
+
154
241
As shown in the following, `compression=estargz` creates an eStargz-formatted image.
155
-
Specifying `oci-mediatypes=true` option is highly recommended for enabling [layer verification](https://github.com/containerd/stargz-snapshotter/blob/v0.6.4/docs/verification.md) of eStargz.
242
+
Specifying `oci-mediatypes=true` option is highly recommended for enabling [layer verification](https://github.com/containerd/stargz-snapshotter/blob/v0.13.0/docs/estargz.md#content-verification-in-estargz) of eStargz.
156
243
157
244
```
158
245
buildctl build ... \
@@ -167,12 +254,14 @@ buildctl build ... \
167
254
168
255
### Other methods to obtain stargz/eStargz images
169
256
170
-
Pre-converted stargz/eStargz images are available at [`ghcr.io/stargz-containers` repository](https://github.com/containerd/stargz-snapshotter/blob/master/docs/pre-converted-images.md) (mainly for testing purpose).
257
+
Pre-converted stargz/eStargz images are available at [`ghcr.io/stargz-containers` repository](https://github.com/containerd/stargz-snapshotter/blob/main/docs/pre-converted-images.md) (mainly for testing purpose).
171
258
172
259
You can also create any stargz/eStargz image using the variety of tools including the following.
173
260
174
-
-[`nerdctl`](https://github.com/containerd/nerdctl/blob/v0.10.0/docs/stargz.md#building-stargz-images-using-nerdctl-build): Docker-compatible CLI for containerd and BuildKit. This supports `convert` subcommand to convert an OCI/Docker image into eStargz.
175
-
-[`ctr-remote`](https://github.com/containerd/stargz-snapshotter/blob/v0.6.4/docs/ctr-remote.md): containerd CLI developed in stargz snapshotter project. This supports converting an OCI/Docker image into eStargz and [optimizing](https://github.com/containerd/stargz-snapshotter/blob/v0.6.4/docs/stargz-estargz.md#example-use-case-of-prioritized-files-workload-based-image-optimization-in-stargz-snapshotter) it.
261
+
-[Docker Buildx](https://github.com/containerd/stargz-snapshotter/tree/v0.13.0#building-estargz-images-using-buildkit): Docker CLI plugin for BuildKit.
262
+
-[Kaniko](https://github.com/containerd/stargz-snapshotter/tree/v0.13.0#building-estargz-images-using-kaniko): An image builder runnable in containers and Kubernetes.
263
+
-[nerdctl](https://github.com/containerd/nerdctl/blob/v1.0.0/docs/stargz.md#building-stargz-images-using-nerdctl-build): Docker-compatible CLI for containerd and BuildKit. This supports `convert` subcommand to convert an OCI/Docker image into eStargz.
264
+
-[`ctr-remote`](https://github.com/containerd/stargz-snapshotter/blob/v0.13.0/docs/ctr-remote.md): containerd CLI developed in stargz snapshotter project. This supports converting an OCI/Docker image into eStargz and [optimizing](https://github.com/containerd/stargz-snapshotter/blob/v0.13.0/docs/estargz.md#example-use-case-of-prioritized-files-workload-based-image-optimization-in-stargz-snapshotter) it.
176
265
-[`stargzify`](https://github.com/google/crfs/tree/master/stargz/stargzify): CLI tool to convert an OCI/Docker image to stargz. This is developed in CRFS project. Creating eStargz is unsupported.
177
266
178
267
There also other tools including Kaniko, ko, builpacks.io that support eStargz creation.
0 commit comments