Last active
August 29, 2015 14:23
-
-
Save carlossg/3bbdfaf007dc3d445307 to your computer and use it in GitHub Desktop.
Docker shared mount
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo umount /mnt/xvdb | |
$ cat /proc/self/mountinfo | grep mnt | |
67 22 202:1 /mnt /mnt rw,relatime shared:1 - ext4 /dev/disk/by-uuid/e1d70192-1bb0-461d-b89f-b054e45bfa00 rw,discard,data=ordered | |
$ docker --version | |
Docker version 1.7.0-rc2, build 7ddecf7 | |
$ docker run -d --name test -v /mnt/xvdb:/mnt busybox tail -f /dev/null | |
9865a125bd2d43cb06887e821e1b298fdee944bb72604edb2f5862619c1a200a | |
$ ls -laF /mnt/xvdb | |
total 8 | |
drwxr-xr-x 2 root root 4096 Jun 17 20:05 ./ | |
drwxr-xr-x 6 root root 4096 Jun 17 20:05 ../ | |
$ docker exec test ls -alF /mnt | |
total 8 | |
drwxr-xr-x 2 root root 4096 Jun 17 20:05 ./ | |
drwxr-xr-x 23 root root 4096 Jun 17 20:16 ../ | |
$ sudo mount /dev/xvdb /mnt/xvdb | |
$ ls -laF /mnt/xvdb | |
total 12 | |
drwxr-xr-x 3 root root 4096 Jun 17 20:14 ./ | |
drwxr-xr-x 6 root root 4096 Jun 17 20:05 ../ | |
drwxr-xr-x 3 root root 4096 May 29 14:32 joc/ | |
-rw-r--r-- 1 root root 0 Jun 17 20:14 test | |
$ docker exec test ls -alF /mnt | |
total 12 | |
drwxr-xr-x 3 root root 4096 Jun 17 20:14 ./ | |
drwxr-xr-x 23 root root 4096 Jun 17 20:16 ../ | |
drwxr-xr-x 3 root root 4096 May 29 14:32 joc/ | |
-rw-r--r-- 1 root root 0 Jun 17 20:14 test | |
# Files match in host and container |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo umount /mnt/xvdb | |
$ sudo umount /mnt | |
$ sudo mount --bind /mnt /mnt | |
$ sudo mount --make-shared /mnt | |
$ sudo service docker restart | |
docker stop/waiting | |
docker start/running, process 2349 | |
$ sudo umount /mnt/xvdb | |
umount: /mnt/xvdb: not mounted | |
$ cat /proc/self/mountinfo | grep mnt | |
43 22 202:1 /mnt /mnt rw,relatime shared:1 - ext4 /dev/disk/by-uuid/e1d70192-1bb0-461d-b89f-b054e45bfa00 rw,discard,data=ordered | |
$ docker --version | |
Docker version 1.7.0-rc5, build f417602 | |
$ docker run -d --name test -v /mnt/xvdb:/mnt busybox tail -f /dev/null | |
09d9350532354326e746242e5c7c76bfe6eadcc3f0571630219830de93e312ae | |
$ ls -laF /mnt/xvdb | |
total 8 | |
drwxr-xr-x 2 root root 4096 Jun 17 16:23 ./ | |
drwxr-xr-x 4 root root 4096 Jun 17 17:32 ../ | |
$ docker exec test ls -alF /mnt | |
total 8 | |
drwxr-xr-x 2 root root 4096 Jun 17 16:23 ./ | |
drwxr-xr-x 23 root root 4096 Jun 17 20:28 ../ | |
$ sudo mount /dev/xvdb /mnt/xvdb | |
$ ls -laF /mnt/xvdb | |
total 8 | |
drwxr-xr-x 2 root root 4096 Jun 17 19:54 ./ | |
drwxr-xr-x 4 root root 4096 Jun 17 17:32 ../ | |
-rw-r--r-- 1 root root 0 Jun 17 19:54 test | |
$ docker exec test ls -alF /mnt | |
total 8 | |
drwxr-xr-x 2 root root 4096 Jun 17 16:23 ./ | |
drwxr-xr-x 23 root root 4096 Jun 17 20:28 ../ | |
# NOTE that test file is not present |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment