|
@@ -6,10 +6,12 @@ import (
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
"os"
|
|
"os"
|
|
"path"
|
|
"path"
|
|
|
|
+ "path/filepath"
|
|
"strings"
|
|
"strings"
|
|
"testing"
|
|
"testing"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
+ "github.com/docker/docker/pkg/mount"
|
|
"github.com/docker/docker/runconfig"
|
|
"github.com/docker/docker/runconfig"
|
|
)
|
|
)
|
|
|
|
|
|
@@ -385,6 +387,21 @@ func TestBindMounts(t *testing.T) {
|
|
t.Fatal("Container failed to read from bind mount")
|
|
t.Fatal("Container failed to read from bind mount")
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Test recursive bind mount works by default
|
|
|
|
+ // Create a temporary tmpfs mount.
|
|
|
|
+ tmpfsDir := filepath.Join(tmpDir, "tmpfs")
|
|
|
|
+ if err := os.MkdirAll(tmpfsDir, 0777); err != nil {
|
|
|
|
+ t.Fatalf("failed to mkdir at %s - %s", tmpfsDir, err)
|
|
|
|
+ }
|
|
|
|
+ if err := mount.Mount("tmpfs", tmpfsDir, "tmpfs", ""); err != nil {
|
|
|
|
+ t.Fatalf("failed to create a tmpfs mount at %s - %s", tmpfsDir, err)
|
|
|
|
+ }
|
|
|
|
+ writeFile(path.Join(tmpfsDir, "touch-me-again"), "", t)
|
|
|
|
+ stdout, _ = runContainer(eng, r, []string{"-v", fmt.Sprintf("%s:/tmp:ro", tmpDir), "_", "ls", "/tmp/tmpfs"}, t)
|
|
|
|
+ if !strings.Contains(stdout, "touch-me-again") {
|
|
|
|
+ t.Fatal("Container recursive bind mount test failed. Expected file not found")
|
|
|
|
+ }
|
|
|
|
+
|
|
// test writing to bind mount
|
|
// test writing to bind mount
|
|
runContainer(eng, r, []string{"-v", fmt.Sprintf("%s:/tmp:rw", tmpDir), "_", "touch", "/tmp/holla"}, t)
|
|
runContainer(eng, r, []string{"-v", fmt.Sprintf("%s:/tmp:rw", tmpDir), "_", "touch", "/tmp/holla"}, t)
|
|
readFile(path.Join(tmpDir, "holla"), t) // Will fail if the file doesn't exist
|
|
readFile(path.Join(tmpDir, "holla"), t) // Will fail if the file doesn't exist
|