diff --git a/layers.go b/layers.go index dc4356ca77..c5f9262735 100644 --- a/layers.go +++ b/layers.go @@ -4,6 +4,7 @@ import ( "bytes" "compress/gzip" "encoding/json" + "fmt" "io" "io/ioutil" "os" @@ -651,6 +652,12 @@ func (r *layerStore) Mount(id, mountLabel string, uidMaps, gidMaps []idtools.IDM if mountLabel == "" { mountLabel = layer.MountLabel } + + if (uidMaps != nil || gidMaps != nil) && !r.driver.SupportsShifting() { + if !reflect.DeepEqual(uidMaps, layer.UIDMap) || !reflect.DeepEqual(gidMaps, layer.GIDMap) { + return "", fmt.Errorf("cannot mount layer %v: shifting not enabled", layer.ID) + } + } mountpoint, err := r.driver.Get(id, mountLabel, uidMaps, gidMaps) if mountpoint != "" && err == nil { if layer.MountPoint != "" {