mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
add test to ensure / can't be bind mounted
This adds a test which checks that we're erroring out when we attempt to bind mount root in a container.
This commit is contained in:
parent
4b8c41c4a2
commit
f1f39616eb
1 changed files with 18 additions and 0 deletions
|
@ -660,4 +660,22 @@ func TestCmdLogs(t *testing.T) {
|
||||||
if err := cli.CmdLogs(globalRuntime.List()[0].ID); err != nil {
|
if err := cli.CmdLogs(globalRuntime.List()[0].ID); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Expected behaviour: using / as a bind mount source should throw an error
|
||||||
|
func TestRunErrorBindMountRootSource(t *testing.T) {
|
||||||
|
|
||||||
|
cli := NewDockerCli(nil, nil, ioutil.Discard, testDaemonProto, testDaemonAddr)
|
||||||
|
defer cleanup(globalRuntime)
|
||||||
|
|
||||||
|
c := make(chan struct{})
|
||||||
|
go func() {
|
||||||
|
defer close(c)
|
||||||
|
if err := cli.CmdRun("-v", "/:/tmp", unitTestImageID, "echo 'should fail'"); err == nil {
|
||||||
|
t.Fatal("should have failed to run when using / as a source for the bind mount")
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
setTimeout(t, "CmdRun timed out", 5*time.Second, func() {
|
||||||
|
<-c
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue