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.
Upstream-commit: 4b8c41c4a2591797f97ad079e4314b21498ba732
Component: engine
This commit is contained in:
unclejack
2013-10-19 01:44:06 +03:00
parent a193590012
commit 26ce0d7e39
+3
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)