Skip to content

Commit 64fbc10

Browse files
committed
Update docs for exec command
1 parent d2e204a commit 64fbc10

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,25 @@ For example:
5151

5252
```bash
5353
# Run an interactive bash shell in the vscode-remote-test-dockerfile devcontainer
54-
devcontainer exec vscode-remote-test-dockerfile bash
54+
devcontainer exec --name vscode-remote-test-dockerfile bash
5555

5656
# Run a command with args in the vscode-remote-test-dockercompose_devcontainer/mongo devcontainer
57-
devcontainer exec vscode-remote-test-dockercompose_devcontainer/mongo ls -a /workspaces/vscode-remote-test-dockerfile
57+
devcontainer exec --name vscode-remote-test-dockercompose_devcontainer/mongo ls -a /workspaces/vscode-remote-test-dockerfile
58+
59+
# Run `bash` in the dev container for the project at `~/ source/my-proj`
60+
devcontainer exec --path ~/source/my-proj bash
61+
62+
# If none of --name/--path/--prompt are specified then `--path .` is assumed (i.e. use the dev container for the current directory)
63+
devcontainer exec bash
64+
65+
# If command/args not set, `bash` is assumed
66+
devcontainer exec --name vscode-remote-test-dockerfile
67+
68+
# Combining these to launch bash in the dev container for the project in the current directory:
69+
devcontainer exec
5870
```
5971

60-
You can pass `?` as the devcontainer name and the CLI will prompt you to pick a devcontainer to run the `exec` command against, e.g.:
72+
You can use `--prompt` instead of `--name` or `--path` and the CLI will prompt you to pick a devcontainer to run the `exec` command against, e.g.:
6173

6274
```bash
6375
$ ./devcontainer exec ? bash
@@ -74,10 +86,12 @@ You can use this with Windows Terminal profiles:
7486
"guid": "{4b304185-99d2-493c-940c-ae74e0f14bba}",
7587
"hidden": false,
7688
"name": "devcontainer exec",
77-
"commandline": "wsl bash -c \"path/to/devcontainer exec ? bash\"",
89+
"commandline": "wsl bash -c \"path/to/devcontainer exec --prompt bash\"",
7890
},
7991
```
8092

93+
By default, `devcontainer exec` will set the working directory to be the mount path for the dev container. This can be overridden using `--work-dir`.
94+
8195
### Working with devcontainer templates
8296

8397
To work with devcontainer templates `devcontainer` needs to know where you have the templates stored.

0 commit comments

Comments
 (0)