Browse Source

Merge pull request #6854 from tomfotherby/patch-1

Add documention on how to Mount a Host File as a Data Volume
Sven Dowideit 11 years ago
parent
commit
d9265007a0
1 changed files with 18 additions and 0 deletions
  1. 18 0
      docs/sources/userguide/dockervolumes.md

+ 18 - 0
docs/sources/userguide/dockervolumes.md

@@ -71,6 +71,24 @@ read-only.
 Here we've mounted the same `/src/webapp` directory but we've added the `ro`
 Here we've mounted the same `/src/webapp` directory but we've added the `ro`
 option to specify that the mount should be read-only.
 option to specify that the mount should be read-only.
 
 
+### Mount a Host File as a Data Volume
+
+The `-v` flag can also be used to mount a single file  - instead of *just* 
+directories - from the host machine.
+
+    $ sudo docker run --rm -it -v ~/.bash_history:/.bash_history ubuntu /bin/bash
+
+This will drop you into a bash shell in a new container, you will have your bash 
+history from the host and when you exit the container, the host will have the 
+history of the commands typed while in the container.
+
+> **Note:** 
+> Many tools used to edit files including `vi` and `sed --in-place` may result 
+> in an inode change. Since Docker v1.1.0, this will produce an error such as
+> "*sed: cannot rename ./sedKdJ9Dy: Device or resource busy*". In the case where 
+> you want to edit the mounted file, it is often easiest to instead mount the 
+> parent directory.
+
 ## Creating and mounting a Data Volume Container
 ## Creating and mounting a Data Volume Container
 
 
 If you have some persistent data that you want to share between
 If you have some persistent data that you want to share between