You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-140Lines changed: 2 additions & 140 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,144 +37,6 @@ alias dc=devcontainer
37
37
complete -F __start_devcontainer dc
38
38
```
39
39
40
-
## Usage
40
+
## Docs
41
41
42
-
### Working with devcontainers
43
-
44
-
#### Listing devcontainers
45
-
46
-
To see which running devcontainers the CLI detects you can run the `list` command.
47
-
48
-
#### Running commands inside a devcontainer
49
-
50
-
`devcontainer` allows you to run commands in devcontainers. This is similar to `docker exec` but works with devcontainer names (rather than requiring container names/IDs).
51
-
52
-
For example:
53
-
54
-
```bash
55
-
# Run an interactive bash shell in the vscode-remote-test-dockerfile devcontainer
There are some other benefits of `devcontainer exec` compared to `docker exec`:
97
-
- it sets the working directory to be the mount path for the dev container. This can be overridden using `--work-dir`.
98
-
- it checks whether you have [configured a user in the dev container](https://code.visualstudio.com/docs/remote/containers-advanced#_adding-a-nonroot-user-to-your-dev-container) and uses this user for the `docker exec`.
99
-
- it checks whether you have set up an SSH agent. If you have and VS Code detects it then VS Code will [forward key requests from the container](https://code.visualstudio.com/docs/remote/containers#_using-ssh-keys). In this scenario, `devcontainer exec` configures the exec session to also forward key requests. This enables operations against git remotes secured with SSH keys to succeed.
100
-
101
-
### Working with devcontainer templates
102
-
103
-
To work with devcontainer templates `devcontainer` needs to know where you have the templates stored.
104
-
105
-
As a quickstart, clone the VS Code devcontainers repo: `git clone https://github.com/microsoft/vscode-dev-containers`
106
-
107
-
Next, run `devcontainer config write` to save a config file and then open `~/.devcontainer-cli/devcontainer-cli.json` in your favourite editor.
108
-
109
-
The starting configuration will look something like:
110
-
111
-
```json
112
-
{
113
-
"templatepaths": []
114
-
}
115
-
```
116
-
117
-
Update to include the path to the `containers` folder in the `vscode-dev-containers` repo you just cloned:
See [Template Paths](#template-paths) for more details of the structure of template folders.
126
-
127
-
#### Listing templates
128
-
129
-
Running `devcontainer template list` will show the templates that `devcontainer` discovered
130
-
131
-
#### Adding a devcontainer
132
-
133
-
To add the files for a devcontainer definition to your project, change directory to the folder you want to add the devcontainer to and then run:
134
-
135
-
```bash
136
-
# Add the go template
137
-
devcontainer template add go
138
-
```
139
-
140
-
This will copy in the template files for you to modify as you wish.
141
-
142
-
#### Adding a link to a devcontainer
143
-
144
-
If you are working with a codebase that you don't want to commit the devcontainer definition to (e.g. an OSS project that doesn't want a devcontainer definition), you can use the `template add-link` command. Instead of copying template files it creates symlinks to the template files and adds a `.gitignore` file to avoid accidental git commits.
145
-
146
-
As with `template add`, run this from the folder you want to add the devcontainer to:
147
-
148
-
```bash
149
-
# Symlink to the go template
150
-
devcontainer template add-link go
151
-
```
152
-
153
-
## Template paths
154
-
155
-
`devcontainer` can be [configured to scan multiple folders](#working-with-devcontainer-templates) to find templates. It is designed to work with folders structured in the same was as the [containers from in github.com/microsoft/vscode-dev-containers](https://github.com/microsoft/vscode-dev-containers/tree/main/containers).
156
-
157
-
Assuming you cloned [github.com/microsoft/vscode-dev-containers/](https://github.com/microsoft/vscode-dev-containers/) into your `~/source/` folder and set up a custom devcontainer folder in `~/source/devcontainers` then you can configure your template paths as shown below. The sub-folder names are used as the template name and when duplicates are found the first matching folder is taken, so in the example below the `~/source/devcontainers` templates take precedence.
158
-
159
-
```json
160
-
{
161
-
"templatepaths": [
162
-
"$HOME/source/devcontainers",
163
-
"$HOME/source/vscode-dev-containers/containers"
164
-
]
165
-
}
166
-
```
167
-
168
-
The structure for these template paths is shown in the following tree structure:
169
-
170
-
```misc
171
-
template-collection-folder
172
-
|-template1
173
-
| |-.devcontainer
174
-
| | |-devcontainer.json
175
-
| | |-Dockerfile
176
-
| | |-<other content for the template>
177
-
|-misc-folder
178
-
|-<misc content that is ignored as there is no .devcontainer folder>
179
-
|-<README or other files that are ignore>
180
-
```
42
+
See [the documentation](https://stuartleeks.github.io/devcontainer-cli) on how to work with `devcontainer`.
0 commit comments