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
Copy file name to clipboardExpand all lines: docs/content-flow.md
+61-13Lines changed: 61 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -16,11 +16,12 @@ Content exists in several areas in the containerd lifecycle:
16
16
* containerd content store, under containerd's local storage space, for example, on a standard Linux installation at `/var/lib/containerd/io.containerd.content.v1.content`
17
17
* snapshots, under containerd's local storage space, for example, on a standard Linux installation at `/var/lib/containerd/io.containerd.snapshotter.v1.<type>`. For an overlayfs snapshotter, that would be at `/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs`
18
18
19
+
A container needs a mountable, and often mutable, filesystem to run. This filesystem is created from the content in the content store.
19
20
In order to create a container, the following must occur:
20
21
21
-
1. The image and all its content must be loaded into the content store. This normally happens via download from the OCI registry, but you can load content in directly as well.
22
-
1.Committed snapshots must be created from each layer of content for the image.
23
-
1.An active snapshot must be created on top of the final layer of content for the image.
22
+
1. The image and all its content must be loaded into the local content store. This normally happens via download from the OCI registry, but you can load content in directly as well. This content is in the same format as in the registry.
23
+
1.The layers from the image must be read and applied to a filesystem, creating what is known as a "committed snapshot". This is repeated for each layer in order. This process is known as "unpacking".
24
+
1.A final mutable mountable filesystem, an "active snapshot", must be created on top of the final layer of content for the image.
24
25
25
26
A container now can be created, with its root filesystem as the active snapshot.
26
27
@@ -351,11 +352,16 @@ they aren't there, they won't be removed.
351
352
352
353
### Snapshots
353
354
354
-
The content in the content store is immutable, but also in formats that often are unusable. For example,
355
-
most container layers are in a tar-gzip format. One cannot simply mount a tar-gzip file. Even if one could,
356
-
we want to leave our immutable content not only unchanged, but unchangeable, even by accident, i.e. immutable.
355
+
The content in the content store is unusable directly by containers.
357
356
358
-
In order to use it, we create snapshots of the content.
357
+
First, it is immutable, which makes it difficult for containers to use as a container filesystem.
358
+
Second, the format itself often is unusable directly. For example,
359
+
most container layers are in a tar-gzip format, with each tar-gzip file representing a single layer to be applied on top of the previous layers.
360
+
One cannot simply mount a tar-gzip file. Even if one could, one would need to apply the changes from each layer on top of the previous.
361
+
Third, some content layer media-types, like the standard container layer, include not only normal file additions and modifications,
362
+
but removals. None of this can be used directly by a container, which requires a normal filesystem mount.
363
+
364
+
In order to use the content for an image, we create snapshots of the content.
359
365
360
366
The process is as follows:
361
367
@@ -364,21 +370,43 @@ The process is as follows:
364
370
1. The snapshotter commits the snapshot after the diff has been applied. This is now a "committed" snapshot.
365
371
1. The committed snapshot is used as the parent for the next layer.
366
372
373
+
containerd ships with several built-in snapshotters, the default of which is `overlayfs`. You can choose a different snapshotter for each unpack
374
+
of an image and creating a container. See [snapshotters](./snapshotters/README.md) and [PLUGINS](./PLUGINS.md).
375
+
367
376
Returning to our example, each layer will have a corresponding immutable snapshot layer. Recalling that
368
377
our example has 6 layers, we expect to see 6 committed snapshots. The output has been sorted to make viewing
369
378
easier; it matches the layers from the content store and manifest itself.
The same 6 committed layers exist, but only 2 new active snapshots are created, one for each container. Both have the parent of the top committed snapshot,
1. Get the content into the content store, either via [Pull()](https://godoc.org/github.com/containerd/containerd/v2/client#Client.Pull), or via loading it in the [content.Store API](https://godoc.org/github.com/containerd/containerd/v2/content#Store)
431
-
1. Unpack the image to create committed snapshots for each layer, using [image.Unpack()](https://godoc.org/github.com/containerd/containerd/v2/client#Image). Alternatively, if you use [Pull()](https://godoc.org/github.com/containerd/containerd/v2/client#Client.Pull), you can pass it an option to unpack when pulling, using [WithPullUnpack()](https://godoc.org/github.com/containerd/containerd/v2/client#WithPullUnpack)
479
+
1. Unpack the image to create committed snapshots for each layer, using [image.Unpack()](https://godoc.org/github.com/containerd/containerd/v2/client#Image). Alternatively, if you use [Pull()](https://godoc.org/github.com/containerd/containerd/v2/client#Client.Pull), you can pass it an option to unpack when pulling, using [WithPullUnpack()](https://godoc.org/github.com/containerd/containerd/v2/client#WithPullUnpack).
432
480
1. Create an active snapshot using [Prepare()](https://godoc.org/github.com/containerd/containerd/v2/snapshots#Snapshotter). You can skip this step if you plan on creating a container, as you can pass it as an option to the next step.
433
481
1. Create a container using [NewContainer()](https://godoc.org/github.com/containerd/containerd/v2/client#Client.NewContainer), optionally telling it to create a snapshot with [WithNewSnapshot()](https://godoc.org/github.com/containerd/containerd/v2/client#WithNewSnapshot)
0 commit comments