summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorAditya Rajan <arajan@redhat.com>2021-09-20 15:38:51 +0530
committerAditya Rajan <arajan@redhat.com>2021-09-21 13:06:23 +0530
commitae5de8b390693784fc383b4d1df85aa92104f481 (patch)
tree2f5d3705ba132ad99cd394fb7a85c1d4ac0e5353 /libpod
parentb925d707fa768245b3bd50d570b91992c1814dba (diff)
downloadpodman-ae5de8b390693784fc383b4d1df85aa92104f481.tar.gz
podman-ae5de8b390693784fc383b4d1df85aa92104f481.tar.bz2
podman-ae5de8b390693784fc383b4d1df85aa92104f481.zip
volume: Add support for overlay on named volumes
Following PR allows containers to create and mount overlays on top of named volumes instead of mounting actual volumes via already documented `:O`. Signed-off-by: Aditya Rajan <arajan@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_internal_linux.go45
1 files changed, 39 insertions, 6 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index dbecea031..0a663200a 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -369,13 +369,46 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
if err != nil {
return nil, err
}
- volMount := spec.Mount{
- Type: "bind",
- Source: mountPoint,
- Destination: namedVol.Dest,
- Options: namedVol.Options,
+
+ overlayFlag := false
+ for _, o := range namedVol.Options {
+ if o == "O" {
+ overlayFlag = true
+ }
+ }
+
+ if overlayFlag {
+ contentDir, err := overlay.TempDir(c.config.StaticDir, c.RootUID(), c.RootGID())
+ if err != nil {
+ return nil, err
+ }
+ overlayMount, err := overlay.Mount(contentDir, mountPoint, namedVol.Dest, c.RootUID(), c.RootGID(), c.runtime.store.GraphOptions())
+ if err != nil {
+ return nil, errors.Wrapf(err, "mounting overlay failed %q", mountPoint)
+ }
+
+ for _, o := range namedVol.Options {
+ switch o {
+ case "U":
+ if err := chown.ChangeHostPathOwnership(mountPoint, true, int(hostUID), int(hostGID)); err != nil {
+ return nil, err
+ }
+
+ if err := chown.ChangeHostPathOwnership(contentDir, true, int(hostUID), int(hostGID)); err != nil {
+ return nil, err
+ }
+ }
+ }
+ g.AddMount(overlayMount)
+ } else {
+ volMount := spec.Mount{
+ Type: "bind",
+ Source: mountPoint,
+ Destination: namedVol.Dest,
+ Options: namedVol.Options,
+ }
+ g.AddMount(volMount)
}
- g.AddMount(volMount)
}
// Check if the spec file mounts contain the options z, Z or U.