|
| 1 | +// Package overlay uses the overlay union filesystem for containers |
| 2 | +// with diff directories for each layer. |
| 3 | +// |
| 4 | +// # Requirements |
| 5 | +// |
| 6 | +// This version of the overlay driver requires at least Linux kernel |
| 7 | +// 4.0.0 in order to support mounting multiple diff directories. |
| 8 | +// |
| 9 | +// # Layout stability |
| 10 | +// |
| 11 | +// The documentation below describes the current data layout; it |
| 12 | +// is however an internal implementation of this package, and |
| 13 | +// may change incompatibly in the future. Do not directly parse |
| 14 | +// or access the files or directories described here; only access |
| 15 | +// them via the higher level Go APIs (or a higher level CLI/API |
| 16 | +// which use the Go APIs, such as `podman`). |
| 17 | +// |
| 18 | +// # The "overlay/" directory |
| 19 | +// |
| 20 | +// This directory holds layers; the sha256 digest here is a |
| 21 | +// "chain ID" identifying the precise sequence of parent1→parent2→…→child |
| 22 | +// layer IDs; and with zstd:chunked, also identifying the contents of the |
| 23 | +// layer depending on how we actually created it. |
| 24 | +// I.e. a layer with the same DiffID can have several physical objects in this directory. |
| 25 | +// More on "chain ID" in [opencontainers ChainID]. |
| 26 | +// |
| 27 | +// Each layer has at least a "diff" directory and "link" file. |
| 28 | +// If there is also a "lower" file when there are diff layers |
| 29 | +// below as well as "merged" and "work" directories. The "diff" directory |
| 30 | +// has the upper layer of the overlay and is used to capture any |
| 31 | +// changes to the layer. The "lower" file contains all the lower layer |
| 32 | +// mounts separated by ":" and ordered from uppermost to lowermost |
| 33 | +// layers. The overlay itself is mounted in the "merged" directory, |
| 34 | +// and the "work" dir is needed for overlay to work. |
| 35 | +// |
| 36 | +// The "link" file for each layer contains a unique string for the layer. |
| 37 | +// Under the "l" directory at the root there will be a symbolic link |
| 38 | +// with that unique string pointing the "diff" directory for the layer. |
| 39 | +// The symbolic links are used to reference lower layers in the "lower" |
| 40 | +// file and on mount. The links are used to shorten the total length |
| 41 | +// of a layer reference without requiring changes to the layer identifier |
| 42 | +// or root directory. Mounts are always done relative to root and |
| 43 | +// referencing the symbolic links in order to ensure the number of |
| 44 | +// lower directories can fit in a single page for making the mount |
| 45 | +// syscall. A hard upper limit of 500 lower layers is enforced to ensure |
| 46 | +// that mounts do not fail due to length. |
| 47 | +// |
| 48 | +// # The "overlay-layers" directory |
| 49 | +// |
| 50 | +// Created by [storage.getLayerStoreLocked]. |
| 51 | +// |
| 52 | +// Each layer will have a `${layerid}.tar-split.gz` file containing the |
| 53 | +// original input tar stream without file content; this is necessary |
| 54 | +// to be able to reconstruct the original tar stream exactly after |
| 55 | +// a layer content has been unpacked into `diff/`. More in [tar-split]. |
| 56 | +// |
| 57 | +// Other files in this directory: |
| 58 | +// |
| 59 | +// - layers.json: Global metadata associated with layers |
| 60 | +// - volatile-layers.json: Global metadata, but will not persist across reboot |
| 61 | +// - layers.lock: Protects changes to this directory |
| 62 | +// |
| 63 | +// # The "overlay-containers" directory |
| 64 | +// |
| 65 | +// Created by [storage.load]. This directory holds running container images. |
| 66 | +// |
| 67 | +// - containers.json: Global metadata for containers |
| 68 | +// - volatile-containers.json: Global metadata, but will not persist across reboot |
| 69 | +// - containers.lock: Protects changes to this directory |
| 70 | +// |
| 71 | +// [opencontainers ChainID]: https://github.com/opencontainers/image-spec/blob/main/config.md#layer-chainid |
| 72 | +// [tar-split]: https://github.com/vbatts/tar-split |
| 73 | + |
1 | 74 | //go:build linux
|
2 | 75 | // +build linux
|
3 | 76 |
|
@@ -51,33 +124,6 @@ const (
|
51 | 124 | mountProgramFlagFile = ".has-mount-program"
|
52 | 125 | )
|
53 | 126 |
|
54 |
| -// This backend uses the overlay union filesystem for containers |
55 |
| -// with diff directories for each layer. |
56 |
| - |
57 |
| -// This version of the overlay driver requires at least kernel |
58 |
| -// 4.0.0 in order to support mounting multiple diff directories. |
59 |
| - |
60 |
| -// Each container/image has at least a "diff" directory and "link" file. |
61 |
| -// If there is also a "lower" file when there are diff layers |
62 |
| -// below as well as "merged" and "work" directories. The "diff" directory |
63 |
| -// has the upper layer of the overlay and is used to capture any |
64 |
| -// changes to the layer. The "lower" file contains all the lower layer |
65 |
| -// mounts separated by ":" and ordered from uppermost to lowermost |
66 |
| -// layers. The overlay itself is mounted in the "merged" directory, |
67 |
| -// and the "work" dir is needed for overlay to work. |
68 |
| - |
69 |
| -// The "link" file for each layer contains a unique string for the layer. |
70 |
| -// Under the "l" directory at the root there will be a symbolic link |
71 |
| -// with that unique string pointing the "diff" directory for the layer. |
72 |
| -// The symbolic links are used to reference lower layers in the "lower" |
73 |
| -// file and on mount. The links are used to shorten the total length |
74 |
| -// of a layer reference without requiring changes to the layer identifier |
75 |
| -// or root directory. Mounts are always done relative to root and |
76 |
| -// referencing the symbolic links in order to ensure the number of |
77 |
| -// lower directories can fit in a single page for making the mount |
78 |
| -// syscall. A hard upper limit of 500 lower layers is enforced to ensure |
79 |
| -// that mounts do not fail due to length. |
80 |
| - |
81 | 127 | const (
|
82 | 128 | linkDir = "l"
|
83 | 129 | stagingDir = "staging"
|
|
0 commit comments