bind mounts work for files - give an example, as its very very useful.
| ... | ... |
@@ -1017,7 +1017,7 @@ image is removed. |
| 1017 | 1017 |
-t, --tty=false: Allocate a pseudo-tty |
| 1018 | 1018 |
-u, --user="": Username or UID |
| 1019 | 1019 |
--dns=[]: Set custom dns servers for the container |
| 1020 |
- -v, --volume=[]: Create a bind mount with: [host-dir]:[container-dir]:[rw|ro]. If "container-dir" is missing, then docker creates a new volume. |
|
| 1020 |
+ -v, --volume=[]: Create a bind mount to a directory or file with: [host-path]:[container-path]:[rw|ro]. If a directory "container-path" is missing, then docker creates a new volume. |
|
| 1021 | 1021 |
--volumes-from="": Mount all volumes from the given container(s) |
| 1022 | 1022 |
--entrypoint="": Overwrite the default entrypoint set by the image |
| 1023 | 1023 |
-w, --workdir="": Working directory inside the container |
| ... | ... |
@@ -1102,15 +1102,23 @@ using the container, but inside the current working directory. |
| 1102 | 1102 |
|
| 1103 | 1103 |
.. code-block:: bash |
| 1104 | 1104 |
|
| 1105 |
- $ sudo docker run -v /dont/exist:/foo -w /foo -i -t ubuntu bash |
|
| 1105 |
+ $ sudo docker run -v /doesnt/exist:/foo -w /foo -i -t ubuntu bash |
|
| 1106 | 1106 |
|
| 1107 | 1107 |
When the host directory of a bind-mounted volume doesn't exist, Docker |
| 1108 | 1108 |
will automatically create this directory on the host for you. In the |
| 1109 |
-example above, Docker will create the ``/dont/exist`` folder before |
|
| 1109 |
+example above, Docker will create the ``/doesnt/exist`` folder before |
|
| 1110 | 1110 |
starting your container. |
| 1111 | 1111 |
|
| 1112 | 1112 |
.. code-block:: bash |
| 1113 | 1113 |
|
| 1114 |
+ $ sudo docker run -t -i -v /var/run/docker.sock:/var/run/docker.sock -v ./static-docker:/usr/bin/docker busybox sh |
|
| 1115 |
+ |
|
| 1116 |
+By bind-mounting the docker unix socket and statically linked docker binary |
|
| 1117 |
+(such as that provided by https://get.docker.io), you give the container |
|
| 1118 |
+the full access to create and manipulate the host's docker daemon. |
|
| 1119 |
+ |
|
| 1120 |
+.. code-block:: bash |
|
| 1121 |
+ |
|
| 1114 | 1122 |
$ sudo docker run -p 127.0.0.1:80:8080 ubuntu bash |
| 1115 | 1123 |
|
| 1116 | 1124 |
This binds port ``8080`` of the container to port ``80`` on ``127.0.0.1`` of the |