Add an option to set the working directory.
This makes it possible to simply wrap a command inside a container. This makes it easier to use a container as an unified build environment. Examples: ~/workspace/docker $ docker run -v `pwd`:`pwd` -w `pwd` -i -t ubuntu ls AUTHORS Makefile archive.go changes.go docker [...] docker run -v `pwd`:`pwd` -w `pwd` -i -t ubuntu pwd /home/marco/workspace/docker Upstream-commit: 687d27ab575778196ea646b6d3fa61b6c8e512b0 Component: engine
This commit is contained in:
@@ -129,7 +129,9 @@ Create a container
|
||||
"Dns":null,
|
||||
"Image":"base",
|
||||
"Volumes":{},
|
||||
"VolumesFrom":""
|
||||
"VolumesFrom":"",
|
||||
"WorkingDir":""
|
||||
|
||||
}
|
||||
|
||||
**Example response**:
|
||||
@@ -195,7 +197,9 @@ Inspect a container
|
||||
"Dns": null,
|
||||
"Image": "base",
|
||||
"Volumes": {},
|
||||
"VolumesFrom": ""
|
||||
"VolumesFrom": "",
|
||||
"WorkingDir":""
|
||||
|
||||
},
|
||||
"State": {
|
||||
"Running": false,
|
||||
@@ -746,7 +750,8 @@ Inspect an image
|
||||
,"Dns":null,
|
||||
"Image":"base",
|
||||
"Volumes":null,
|
||||
"VolumesFrom":""
|
||||
"VolumesFrom":"",
|
||||
"WorkingDir":""
|
||||
},
|
||||
"Size": 6824592
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
-v=[]: Create a bind mount with: [host-dir]:[container-dir]:[rw|ro]. If "host-dir" is missing, then docker creates a new volume.
|
||||
-volumes-from="": Mount all volumes from the given container.
|
||||
-entrypoint="": Overwrite the default entrypoint set by the image.
|
||||
-w="": Working directory inside the container
|
||||
|
||||
|
||||
Examples
|
||||
@@ -62,3 +63,22 @@ cgroup controller. In other words, the container can then do almost
|
||||
everything that the host can do. This flag exists to allow special
|
||||
use-cases, like running Docker within Docker.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
docker run -w /path/to/dir/ -i -t ubuntu pwd
|
||||
|
||||
The ``-w`` lets the command beeing executed inside directory given,
|
||||
here /path/to/dir/. If the path does not exists it is created inside the
|
||||
container.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
docker run -v `pwd`:`pwd` -w `pwd` -i -t ubuntu pwd
|
||||
|
||||
The ``-v`` flag mounts the current working directory into the container.
|
||||
The ``-w`` lets the command beeing executed inside the current
|
||||
working directory, by changeing into the directory to the value
|
||||
returned by ``pwd``. So this combination executes the command
|
||||
using the container, but inside the current working directory.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user