introduce —workdir option for docker exec

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof
2017-12-01 08:26:18 +01:00
parent 6b63d7b96a
commit 591a1273fd
5 changed files with 21 additions and 1 deletions

View File

@ -29,6 +29,7 @@ Options:
--privileged Give extended privileges to the command
-t, --tty Allocate a pseudo-TTY
-u, --user Username or UID (format: <name|uid>[:<group|gid>])
-w, --workdir Working directory inside the container
```
## Description
@ -86,6 +87,20 @@ This will create a new Bash session in the container `ubuntu_bash` with environm
variable `$VAR` set to "1". Note that this environment variable will only be valid
on the current Bash session.
By default `docker exec` command runs in the same working directory set when container was created.
```bash
$ docker exec -it ubuntu_bash pwd
/
```
You can select working directory for the command to execute into
```bash
$ docker exec -it -w /root ubuntu_bash pwd
/root
```
### Try to run `docker exec` on a paused container