Skip to content

Commit e805ebb

Browse files
committed
docs: document dev container customization options
Add documentation for Coder-specific devcontainer.json customizations: - Custom agent name via `name` option - Display apps configuration (`displayApps`) - Custom apps with full property reference - Health check configuration - Variable interpolation (${localEnv:...}, Coder variables, $SESSION_TOKEN) - Feature options as environment variables (FEATURE_*_OPTION_*)
1 parent f63d56c commit e805ebb

File tree

1 file changed

+211
-0
lines changed

1 file changed

+211
-0
lines changed

docs/admin/templates/extending-templates/devcontainers.md

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,217 @@ When `autoStart` is set to `false` or omitted:
204204
- The Dev Container is discovered and shown in the UI
205205
- Users must manually start it via the UI
206206

207+
### Custom agent name
208+
209+
Set a custom name for the dev container's agent using the `name` option:
210+
211+
```json
212+
{
213+
"name": "My Dev Container",
214+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
215+
"customizations": {
216+
"coder": {
217+
"name": "my-custom-agent"
218+
}
219+
}
220+
}
221+
```
222+
223+
The name must contain only lowercase letters, numbers, and hyphens. If omitted,
224+
Coder derives the agent name from the workspace folder path (e.g.,
225+
`/home/coder/my-project` becomes `my-project`).
226+
227+
### Display apps
228+
229+
Control which built-in Coder apps appear for the dev container using
230+
`displayApps`:
231+
232+
```json
233+
{
234+
"name": "My Dev Container",
235+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
236+
"customizations": {
237+
"coder": {
238+
"displayApps": {
239+
"web_terminal": true,
240+
"ssh_helper": true,
241+
"port_forwarding_helper": true,
242+
"vscode": true,
243+
"vscode_insiders": false
244+
}
245+
}
246+
}
247+
}
248+
```
249+
250+
Available display apps:
251+
252+
| App | Description |
253+
|--------------------------|------------------------------|
254+
| `web_terminal` | Web-based terminal access |
255+
| `ssh_helper` | SSH connection helper |
256+
| `port_forwarding_helper` | Port forwarding interface |
257+
| `vscode` | VS Code Desktop integration |
258+
| `vscode_insiders` | VS Code Insiders integration |
259+
260+
By default, `web_terminal`, `ssh_helper`, `port_forwarding_helper`, and `vscode`
261+
are enabled.
262+
263+
### Custom apps
264+
265+
Define custom applications for the dev container using the `apps` array:
266+
267+
```json
268+
{
269+
"name": "My Dev Container",
270+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
271+
"customizations": {
272+
"coder": {
273+
"apps": [
274+
{
275+
"slug": "my-web-app",
276+
"displayName": "My Web App",
277+
"url": "http://localhost:3000",
278+
"openIn": "tab",
279+
"share": "owner",
280+
"icon": "/icon/web.svg",
281+
"order": 1
282+
}
283+
]
284+
}
285+
}
286+
}
287+
```
288+
289+
Each app supports the following properties:
290+
291+
| Property | Type | Description |
292+
|---------------|---------|---------------------------------------------------------------|
293+
| `slug` | string | Unique identifier for the app (required) |
294+
| `displayName` | string | Human-readable name shown in the UI |
295+
| `url` | string | URL to open (supports variable interpolation) |
296+
| `command` | string | Command to run instead of opening a URL |
297+
| `icon` | string | Path to an icon (e.g., `/icon/code.svg`) |
298+
| `openIn` | string | `"tab"` or `"slim-window"` (default: `"slim-window"`) |
299+
| `share` | string | `"owner"`, `"authenticated"`, `"organization"`, or `"public"` |
300+
| `external` | boolean | Open as external URL (e.g., for desktop apps) |
301+
| `group` | string | Group name for organizing apps in the UI |
302+
| `order` | number | Sort order for display |
303+
| `hidden` | boolean | Hide the app from the UI |
304+
| `subdomain` | boolean | Use subdomain-based access |
305+
| `healthCheck` | object | Health check configuration (see below) |
306+
307+
#### Health checks
308+
309+
Configure health checks to monitor app availability:
310+
311+
```json
312+
{
313+
"apps": [
314+
{
315+
"slug": "web-server",
316+
"displayName": "Web Server",
317+
"url": "http://localhost:8080",
318+
"healthCheck": {
319+
"url": "http://localhost:8080/healthz",
320+
"interval": 5,
321+
"threshold": 2
322+
}
323+
}
324+
]
325+
}
326+
```
327+
328+
### Variable interpolation
329+
330+
App URLs and other string values support variable interpolation for dynamic
331+
configuration:
332+
333+
#### Environment variables
334+
335+
Use `${localEnv:VAR_NAME}` to reference environment variables, with optional
336+
default values:
337+
338+
```json
339+
{
340+
"url": "http://${localEnv:HOST:127.0.0.1}:${localEnv:PORT:8080}"
341+
}
342+
```
343+
344+
#### Coder-provided variables
345+
346+
Coder provides these environment variables during configuration:
347+
348+
| Variable | Description |
349+
|-------------------------------------|------------------------------------|
350+
| `CODER_WORKSPACE_NAME` | Name of the workspace |
351+
| `CODER_WORKSPACE_OWNER_NAME` | Username of the workspace owner |
352+
| `CODER_WORKSPACE_AGENT_NAME` | Name of the dev container agent |
353+
| `CODER_WORKSPACE_PARENT_AGENT_NAME` | Name of the parent workspace agent |
354+
| `CODER_URL` | URL of the Coder deployment |
355+
| `CONTAINER_ID` | Docker container ID |
356+
357+
#### Dev container variables
358+
359+
Standard dev container variables are also available:
360+
361+
| Variable | Description |
362+
|-------------------------------|--------------------------------------------|
363+
| `${containerWorkspaceFolder}` | Workspace folder path inside the container |
364+
| `${localWorkspaceFolder}` | Workspace folder path on the host |
365+
366+
#### Session token
367+
368+
Use `$SESSION_TOKEN` in external app URLs to include the user's session token:
369+
370+
```json
371+
{
372+
"apps": [
373+
{
374+
"slug": "custom-ide",
375+
"displayName": "Custom IDE",
376+
"url": "custom-ide://open?token=$SESSION_TOKEN&folder=${containerWorkspaceFolder}",
377+
"external": true
378+
}
379+
]
380+
}
381+
```
382+
383+
### Feature options as environment variables
384+
385+
When your dev container uses features, Coder exposes feature options as
386+
environment variables for use in customizations. The format is
387+
`FEATURE_<FEATURE_NAME>_OPTION_<OPTION_NAME>`.
388+
389+
For example, with this feature configuration:
390+
391+
```json
392+
{
393+
"features": {
394+
"ghcr.io/coder/devcontainer-features/code-server:1": {
395+
"port": 9090
396+
}
397+
}
398+
}
399+
```
400+
401+
Coder creates `FEATURE_CODE_SERVER_OPTION_PORT=9090`, which you can reference:
402+
403+
```json
404+
{
405+
"customizations": {
406+
"coder": {
407+
"apps": [
408+
{
409+
"slug": "code-server",
410+
"url": "http://localhost:${localEnv:FEATURE_CODE_SERVER_OPTION_PORT:8080}"
411+
}
412+
]
413+
}
414+
}
415+
}
416+
```
417+
207418
## Complete Template Example
208419

209420
Here's a simplified template example that uses Dev Containers with manual

0 commit comments

Comments
 (0)