diff --git a/daemon/graphdriver/btrfs/btrfs.go b/daemon/graphdriver/btrfs/btrfs.go index dfe5b549f3f98fc8062aabb23e4a1d20e752ad33..86aa631b757b73e6f7f87242a804b1f5b9960823 100644 --- a/daemon/graphdriver/btrfs/btrfs.go +++ b/daemon/graphdriver/btrfs/btrfs.go @@ -266,6 +266,14 @@ func (d *Driver) Create(id, parent, mountLabel string) error { } } + // if we have a remapped root (user namespaces enabled), change the created snapshot + // dir ownership to match + if rootUID != 0 || rootGID != 0 { + if err := os.Chown(path.Join(subvolumes, id), rootUID, rootGID); err != nil { + return err + } + } + return label.Relabel(path.Join(subvolumes, id), mountLabel, false) }