From cfbe062eb2ba6f1d24ab3b6f9b965a65931d5b07 Mon Sep 17 00:00:00 2001 From: Tom Fotherby Date: Fri, 4 Jul 2014 18:52:10 +0100 Subject: [PATCH 1/5] Add info to Mount a Host File as a Data Volume Docker-DCO-1.1-Signed-off-by: Tom Fotherby (github: tomfotherby) --- docs/sources/userguide/dockervolumes.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/sources/userguide/dockervolumes.md b/docs/sources/userguide/dockervolumes.md index 93ac37b1c..fc9a7e0f8 100644 --- a/docs/sources/userguide/dockervolumes.md +++ b/docs/sources/userguide/dockervolumes.md @@ -71,6 +71,21 @@ read-only. 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. +### Mount a Host File as a Data Volume + +As well as directories, the `-v` flag can be used to mount a single file from the host into a container. + + $ 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 your host and when +you exit the container the host will have the history of the commands typed while in the container. + +> **Note:** +> The two-way binding of the mounted file will only be preserved as long as the inode doesn't change. Many +> tools used to edit files including `vi` and `sed --in-place` may result in a inode change. In the case where you +> want to edit the file, it is often best to mount the parent directory. + + ## Creating and mounting a Data Volume Container If you have some persistent data that you want to share between From 87df57810d39bdd50167338e5ff8d0e6bc6e23e2 Mon Sep 17 00:00:00 2001 From: Tom Fotherby Date: Sat, 5 Jul 2014 03:46:41 +0100 Subject: [PATCH 2/5] Update File mount info for docker v1.1.0 Docker-DCO-1.1-Signed-off-by: Tom Fotherby (github: tomfotherby) --- docs/sources/userguide/dockervolumes.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/sources/userguide/dockervolumes.md b/docs/sources/userguide/dockervolumes.md index fc9a7e0f8..f0725d4ad 100644 --- a/docs/sources/userguide/dockervolumes.md +++ b/docs/sources/userguide/dockervolumes.md @@ -78,13 +78,12 @@ As well as directories, the `-v` flag can be used to mount a single file from th $ 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 your host and when -you exit the container the host will have the history of the commands typed while in the container. +you exit the container, the host will have the history of the commands typed while in the container. > **Note:** -> The two-way binding of the mounted file will only be preserved as long as the inode doesn't change. Many -> tools used to edit files including `vi` and `sed --in-place` may result in a inode change. In the case where you -> want to edit the file, it is often best to mount the parent directory. - +> Many tools used to edit files including `vi` and `sed --in-place` may result in a inode change. Since docker v1.1.0 +> this will produce a 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 From ebbfdf0a0f99aac67b8ad5d789d8a400be346c30 Mon Sep 17 00:00:00 2001 From: Tom Fotherby Date: Mon, 7 Jul 2014 12:01:04 +0100 Subject: [PATCH 3/5] Reformat to keep line length within 80 characters Docker-DCO-1.1-Signed-off-by: Tom Fotherby (github: tomfotherby) --- docs/sources/userguide/dockervolumes.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/sources/userguide/dockervolumes.md b/docs/sources/userguide/dockervolumes.md index f0725d4ad..959a01c50 100644 --- a/docs/sources/userguide/dockervolumes.md +++ b/docs/sources/userguide/dockervolumes.md @@ -73,17 +73,21 @@ option to specify that the mount should be read-only. ### Mount a Host File as a Data Volume -As well as directories, the `-v` flag can be used to mount a single file from the host into a container. +As well as directories, the `-v` flag can be used to mount a single file from +the host into a container. $ 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 your host and when -you exit the container, the host will have the history of the commands typed while in the container. +This will drop you into a bash shell in a new container, you will have your bash +history from your 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 a inode change. Since docker v1.1.0 -> this will produce a 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. +> Many tools used to edit files including `vi` and `sed --in-place` may result +> in a inode change. Since docker v1.1.0 this will produce a 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 From a247b63aa18a31cc2aeb8e32c06b040a47764d0b Mon Sep 17 00:00:00 2001 From: Tom Fotherby Date: Tue, 8 Jul 2014 10:01:26 +0100 Subject: [PATCH 4/5] Typo fix Docker-DCO-1.1-Signed-off-by: Tom Fotherby (github: tomfotherby) --- docs/sources/userguide/dockervolumes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sources/userguide/dockervolumes.md b/docs/sources/userguide/dockervolumes.md index 959a01c50..cf504e334 100644 --- a/docs/sources/userguide/dockervolumes.md +++ b/docs/sources/userguide/dockervolumes.md @@ -84,7 +84,7 @@ 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 a inode change. Since docker v1.1.0 this will produce a error such as +> 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. From e479cae7cf86a2929e0439a61565ed7d9100f445 Mon Sep 17 00:00:00 2001 From: Tom Fotherby Date: Wed, 9 Jul 2014 08:21:31 +0100 Subject: [PATCH 5/5] Tiny text reformat (as per review comments) Docker-DCO-1.1-Signed-off-by: Tom Fotherby (github: tomfotherby) --- docs/sources/userguide/dockervolumes.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/sources/userguide/dockervolumes.md b/docs/sources/userguide/dockervolumes.md index cf504e334..02efbf7c1 100644 --- a/docs/sources/userguide/dockervolumes.md +++ b/docs/sources/userguide/dockervolumes.md @@ -73,18 +73,18 @@ option to specify that the mount should be read-only. ### Mount a Host File as a Data Volume -As well as directories, the `-v` flag can be used to mount a single file from -the host into a container. +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 your host and when you exit the container, the host will have the +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 +> 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.