Error out if file in container at volume path

Fixes #4393

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: c73e3bf4dc0382cd188db3e51c52eaf8bf605795
Component: engine
This commit is contained in:
Brian Goff
2015-01-14 22:30:28 -05:00
parent 35392998b3
commit a3cae1498c
2 changed files with 23 additions and 0 deletions

View File

@ -184,6 +184,12 @@ func (container *Container) parseVolumeMountConfig() (map[string]*Mount, error)
continue
}
if stat, err := os.Stat(filepath.Join(container.basefs, path)); err == nil {
if !stat.IsDir() {
return nil, fmt.Errorf("file exists at %s, can't create volume there")
}
}
vol, err := container.daemon.volumes.FindOrCreateVolume("", true)
if err != nil {
return nil, err