disallow / as source for bind mount in the cli

This makes the docker cli reject docker run commands which include bind
mounts like "/:/some/path/in/the/container".
Bind mounting the root directory is a bad idea and the cli should throw
an error right away.

The same check will also be made by the remote API via another commit.
This commit is contained in:
unclejack 2013-10-19 01:44:06 +03:00
parent 114e01cdc1
commit 4b8c41c4a2

View file

@ -251,6 +251,9 @@ func ParseRun(args []string, capabilities *Capabilities) (*Config, *HostConfig,
for bind := range flVolumes {
arr := strings.Split(bind, ":")
if len(arr) > 1 {
if arr[0] == "/" {
return nil, nil, cmd, fmt.Errorf("Invalid bind mount: source can't be '/'")
}
dstDir := arr[1]
flVolumes[dstDir] = struct{}{}
binds = append(binds, bind)