dockerfile: allow relative paths in mount targets

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
docker-18.09
Tonis Tiigi 2018-09-17 11:15:22 -07:00
parent 80f959c7ef
commit b103d7fdd6
1 changed files with 5 additions and 2 deletions

View File

@ -78,9 +78,12 @@ func dispatchRunMounts(d *dispatchState, c *instructions.RunCommand, sources []*
}
mountOpts = append(mountOpts, llb.AsPersistentCacheDir(opt.cacheIDNamespace+"/"+mount.CacheID, sharing))
}
target := path.Join("/", mount.Target)
target := mount.Target
if !filepath.IsAbs(filepath.Clean(mount.Target)) {
target = filepath.Join("/", d.state.GetDir(), mount.Target)
}
if target == "/" {
return nil, errors.Errorf("invalid mount target %q", mount.Target)
return nil, errors.Errorf("invalid mount target %q", target)
}
if src := path.Join("/", mount.Source); src != "/" {
mountOpts = append(mountOpts, llb.SourcePath(src))