mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
7cb96ba308
Validation of Mounts was only performed on container _creation_, not on container _start_. As a result, if the host-path no longer existed when the container was started, a directory was created in the given location. This is the wrong behavior, because when using the `Mounts` API, host paths should never be created, and an error should be produced instead. This patch adds a validation step on container start, and produces an error if the host path is not found. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
35 lines
949 B
Go
35 lines
949 B
Go
package volume
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"path"
|
|
|
|
"github.com/docker/docker/api/types/mount"
|
|
)
|
|
|
|
var lcowSpecificValidators mountValidator = func(m *mount.Mount) error {
|
|
if path.Clean(m.Target) == "/" {
|
|
return fmt.Errorf("invalid specification: destination can't be '/'")
|
|
}
|
|
if m.Type == mount.TypeNamedPipe {
|
|
return errors.New("Linux containers on Windows do not support named pipe mounts")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type lcowParser struct {
|
|
windowsParser
|
|
}
|
|
|
|
func (p *lcowParser) ValidateMountConfig(mnt *mount.Mount) error {
|
|
return p.validateMountConfigReg(mnt, rxLCOWDestination, lcowSpecificValidators)
|
|
}
|
|
|
|
func (p *lcowParser) ParseMountRaw(raw, volumeDriver string) (*MountPoint, error) {
|
|
return p.parseMountRaw(raw, volumeDriver, rxLCOWDestination, false, lcowSpecificValidators)
|
|
}
|
|
|
|
func (p *lcowParser) ParseMountSpec(cfg mount.Mount) (*MountPoint, error) {
|
|
return p.parseMountSpec(cfg, rxLCOWDestination, false, lcowSpecificValidators)
|
|
}
|