Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
| ... | ... |
@@ -75,9 +75,9 @@ lxc.mount.entry = shm {{escapeFstabSpaces $ROOTFS}}/dev/shm tmpfs {{formatMountL
|
| 75 | 75 |
|
| 76 | 76 |
{{range $value := .Mounts}}
|
| 77 | 77 |
{{if $value.Writable}}
|
| 78 |
-lxc.mount.entry = {{$value.Source}} {{escapeFstabSpaces $ROOTFS}}/{{escapeFstabSpaces $value.Destination}} none bind,rw 0 0
|
|
| 78 |
+lxc.mount.entry = {{$value.Source}} {{escapeFstabSpaces $ROOTFS}}/{{escapeFstabSpaces $value.Destination}} none rbind,rw 0 0
|
|
| 79 | 79 |
{{else}}
|
| 80 |
-lxc.mount.entry = {{$value.Source}} {{escapeFstabSpaces $ROOTFS}}/{{escapeFstabSpaces $value.Destination}} none bind,ro 0 0
|
|
| 80 |
+lxc.mount.entry = {{$value.Source}} {{escapeFstabSpaces $ROOTFS}}/{{escapeFstabSpaces $value.Destination}} none rbind,ro 0 0
|
|
| 81 | 81 |
{{end}}
|
| 82 | 82 |
{{end}}
|
| 83 | 83 |
|
| ... | ... |
@@ -6,10 +6,12 @@ import ( |
| 6 | 6 |
"io/ioutil" |
| 7 | 7 |
"os" |
| 8 | 8 |
"path" |
| 9 |
+ "path/filepath" |
|
| 9 | 10 |
"strings" |
| 10 | 11 |
"testing" |
| 11 | 12 |
"time" |
| 12 | 13 |
|
| 14 |
+ "github.com/docker/docker/pkg/mount" |
|
| 13 | 15 |
"github.com/docker/docker/runconfig" |
| 14 | 16 |
) |
| 15 | 17 |
|
| ... | ... |
@@ -385,6 +387,21 @@ func TestBindMounts(t *testing.T) {
|
| 385 | 385 |
t.Fatal("Container failed to read from bind mount")
|
| 386 | 386 |
} |
| 387 | 387 |
|
| 388 |
+ // Test recursive bind mount works by default |
|
| 389 |
+ // Create a temporary tmpfs mount. |
|
| 390 |
+ tmpfsDir := filepath.Join(tmpDir, "tmpfs") |
|
| 391 |
+ if err := os.MkdirAll(tmpfsDir, 0777); err != nil {
|
|
| 392 |
+ t.Fatalf("failed to mkdir at %s - %s", tmpfsDir, err)
|
|
| 393 |
+ } |
|
| 394 |
+ if err := mount.Mount("tmpfs", tmpfsDir, "tmpfs", ""); err != nil {
|
|
| 395 |
+ t.Fatalf("failed to create a tmpfs mount at %s - %s", tmpfsDir, err)
|
|
| 396 |
+ } |
|
| 397 |
+ writeFile(path.Join(tmpfsDir, "touch-me-again"), "", t) |
|
| 398 |
+ stdout, _ = runContainer(eng, r, []string{"-v", fmt.Sprintf("%s:/tmp:ro", tmpDir), "_", "ls", "/tmp/tmpfs"}, t)
|
|
| 399 |
+ if !strings.Contains(stdout, "touch-me-again") {
|
|
| 400 |
+ t.Fatal("Container recursive bind mount test failed. Expected file not found")
|
|
| 401 |
+ } |
|
| 402 |
+ |
|
| 388 | 403 |
// test writing to bind mount |
| 389 | 404 |
runContainer(eng, r, []string{"-v", fmt.Sprintf("%s:/tmp:rw", tmpDir), "_", "touch", "/tmp/holla"}, t)
|
| 390 | 405 |
readFile(path.Join(tmpDir, "holla"), t) // Will fail if the file doesn't exist |