Use mount.Target to specify subdirectory of rootfs mount

- Add Target to mount.Mount.
- Add UnmountMounts to unmount a list of mounts in reverse order.
- Add UnmountRecursive to unmount deepest mount first for a given target, using
moby/sys/mountinfo.

Signed-off-by: Edgar Lee <edgarhinshunlee@gmail.com>
This commit is contained in:
Edgar Lee
2023-01-23 13:36:28 -05:00
parent 753bfd6575
commit 34d5878185
26 changed files with 282 additions and 65 deletions

View File

@@ -24,3 +24,37 @@ Filesystem-specific:
- `nydus`: [Nydus Snapshotter](https://github.com/containerd/nydus-snapshotter)
- `overlaybd`: [OverlayBD Snapshotter](https://github.com/containerd/accelerated-container-image)
- `stargz`: [Stargz Snapshotter](https://github.com/containerd/stargz-snapshotter)
## Mount target
Mounts can optionally specify a target to describe submounts in the container's
rootfs. For example, if the snapshotter wishes to bind mount to a subdirectory
ontop of an overlayfs mount, they can return the following mounts:
```json
[
{
"type": "overlay",
"source": "overlay",
"options": [
"workdir=...",
"upperdir=...",
"lowerdir=..."
]
},
{
"type": "bind",
"source": "/path/on/host",
"target": "/path/inside/container",
"options": [
"ro",
"rbind"
]
}
]
```
However, the mountpoint `/path/inside/container` needs to exist for the bind
mount, so one of the previous mounts must be responsible for providing that
directory in the rootfs. In this case, one of the lower dirs of the overlay has
that directory to enable the bind mount.