@@ -25,7 +25,9 @@ This is the recommended approach for most use cases.
2525
2626### Project Discovery
2727
28- Enable automatic discovery of Dev Containers in Git repositories. Project discovery automatically scans Git repositories for ` .devcontainer/devcontainer.json ` or ` .devcontainer.json ` files and surfaces them in the Coder UI. See the [ Environment Variables] ( #environment-variables ) section for detailed configuration options.
28+ Alternatively, enable automatic discovery of Dev Containers in Git repositories.
29+ The agent scans for ` devcontainer.json ` files and surfaces them in the Coder UI.
30+ See [ Environment Variables] ( #environment-variables ) for configuration options.
2931
3032## Install the Dev Containers CLI
3133
@@ -36,7 +38,7 @@ to ensure the `@devcontainers/cli` is installed in your workspace:
3638``` terraform
3739module "devcontainers-cli" {
3840 count = data.coder_workspace.me.start_count
39- source = "dev. registry.coder.com/modules /devcontainers-cli/coder"
41+ source = "registry.coder.com/coder /devcontainers-cli/coder"
4042 agent_id = coder_agent.dev.id
4143}
4244```
@@ -72,6 +74,10 @@ resource "coder_devcontainer" "my-repository" {
7274> module to ensure your repository is cloned into the workspace folder and ready
7375> for automatic startup.
7476
77+ For multi-repo workspaces, define multiple ` coder_devcontainer ` resources, each
78+ pointing to a different repository. Each one runs as a separate sub-agent with
79+ its own terminal and apps in the dashboard.
80+
7581## Enable Dev Containers Integration
7682
7783Dev Containers integration is ** enabled by default** in Coder 2.24.0 and later.
@@ -119,15 +125,17 @@ by setting this to `false`.
119125
120126Enables automatic discovery of Dev Containers in Git repositories.
121127
122- When enabled, the agent will:
128+ When enabled, the agent scans the configured working directory (set via the
129+ ` directory ` attribute in ` coder_agent ` , typically the user's home directory) for
130+ Git repositories. If the directory itself is a Git repository, it searches that
131+ project. Otherwise, it searches immediate subdirectories for Git repositories.
123132
124- - Scan the agent directory for Git repositories
125- - Look for ` .devcontainer/devcontainer.json ` or ` .devcontainer.json ` files
126- - Surface discovered Dev Containers automatically in the Coder UI
127- - Respect ` .gitignore ` patterns during discovery
133+ For each repository found, the agent looks for ` devcontainer.json ` files in the
134+ [ standard locations ] ( ../../../user-guides/devcontainers/index.md#add-a-devcontainerjson )
135+ and surfaces discovered Dev Containers in the Coder UI. Discovery respects
136+ ` .gitignore ` patterns.
128137
129- You can disable automatic discovery by setting this to ` false ` if you prefer to
130- use only the ` coder_devcontainer ` resource for explicit configuration.
138+ Set to ` false ` if you prefer explicit configuration via ` coder_devcontainer ` .
131139
132140### CODER_AGENT_DEVCONTAINERS_DISCOVERY_AUTOSTART_ENABLE
133141
@@ -142,67 +150,33 @@ always auto-start regardless of this setting.
142150
143151## Per-Container Customizations
144152
145- Individual Dev Containers can be customized using the ` customizations.coder ` block
146- in your ` devcontainer.json ` file. These customizations allow you to control
147- container-specific behavior without modifying your template.
148-
149- ### Ignore Specific Containers
150-
151- Use the ` ignore ` option to hide a Dev Container from Coder completely:
152-
153- ``` json
154- {
155- "name" : " My Dev Container" ,
156- "image" : " mcr.microsoft.com/devcontainers/base:ubuntu" ,
157- "customizations" : {
158- "coder" : {
159- "ignore" : true
160- }
161- }
162- }
163- ```
164-
165- When ` ignore ` is set to ` true ` :
166-
167- - The Dev Container won't appear in the Coder UI
168- - Coder won't manage or monitor the container
169-
170- This is useful when you have Dev Containers in your repository that you don't
171- want Coder to manage.
172-
173- ### Per-Container Auto-Start
174-
175- Control whether individual Dev Containers should auto-start using the
176- ` autoStart ` option:
177-
178- ``` json
179- {
180- "name" : " My Dev Container" ,
181- "image" : " mcr.microsoft.com/devcontainers/base:ubuntu" ,
182- "customizations" : {
183- "coder" : {
184- "autoStart" : true
185- }
186- }
187- }
188- ```
189-
190- ** Important** : The ` autoStart ` option only applies when global auto-start is
191- enabled via ` CODER_AGENT_DEVCONTAINERS_DISCOVERY_AUTOSTART_ENABLE=true ` . If
192- the global setting is disabled, containers won't auto-start regardless of this
193- setting.
194-
195- When ` autoStart ` is set to ` true ` :
153+ > [ !NOTE]
154+ >
155+ > Dev container sub-agents are created dynamically after workspace provisioning,
156+ > so Terraform resources like
157+ > [ ` coder_script ` ] ( https://registry.terraform.io/providers/coder/coder/latest/docs/resources/script )
158+ > and [ ` coder_app ` ] ( https://registry.terraform.io/providers/coder/coder/latest/docs/resources/app )
159+ > cannot currently be attached to them. Modules from the
160+ > [ Coder registry] ( https://registry.coder.com ) that depend on these resources
161+ > are also not currently supported for sub-agents.
162+ >
163+ > To add tools to dev containers, use
164+ > [ dev container features] ( ../../../user-guides/devcontainers/working-with-dev-containers.md#dev-container-features ) .
165+ > For Coder-specific apps, use the
166+ > [ ` apps ` customization] ( ../../../user-guides/devcontainers/customizing-dev-containers.md#custom-apps ) .
196167
197- - The Dev Container automatically builds and starts during workspace
198- initialization
199- - Works on a per-container basis (you can enable it for some containers but not
200- others)
168+ Developers can customize individual dev containers using the ` customizations.coder `
169+ block in their ` devcontainer.json ` file. Available options include:
201170
202- When ` autoStart ` is set to ` false ` or omitted:
171+ - ` ignore ` — Hide a dev container from Coder completely
172+ - ` autoStart ` — Control whether the container starts automatically (requires
173+ ` CODER_AGENT_DEVCONTAINERS_DISCOVERY_AUTOSTART_ENABLE ` to be enabled)
174+ - ` name ` — Set a custom agent name
175+ - ` displayApps ` — Control which built-in apps appear
176+ - ` apps ` — Define custom applications
203177
204- - The Dev Container is discovered and shown in the UI
205- - Users must manually start it via the UI
178+ For the full reference, see
179+ [ Customizing dev containers ] ( ../../../user-guides/devcontainers/customizing-dev-containers.md ) .
206180
207181## Complete Template Example
208182
@@ -232,7 +206,7 @@ resource "coder_agent" "dev" {
232206
233207module "devcontainers-cli" {
234208 count = data.coder_workspace.me.start_count
235- source = "dev. registry.coder.com/modules /devcontainers-cli/coder"
209+ source = "registry.coder.com/coder /devcontainers-cli/coder"
236210 agent_id = coder_agent.dev.id
237211}
238212
@@ -243,9 +217,10 @@ resource "coder_devcontainer" "my-repository" {
243217}
244218```
245219
246- ### Alternative: Project Discovery Mode
220+ ### Alternative: Project Discovery with Autostart
247221
248- You can enable automatic starting of discovered Dev Containers:
222+ By default, discovered containers appear in the dashboard but developers must
223+ manually start them. To have them start automatically, enable autostart:
249224
250225``` terraform
251226resource "docker_container" "workspace" {
@@ -261,20 +236,28 @@ resource "docker_container" "workspace" {
261236}
262237```
263238
264- With this configuration :
239+ With autostart enabled :
265240
266- - Project discovery is enabled (default behavior)
267- - Discovered containers are automatically started (via the env var)
268- - The ` coder_devcontainer ` resource is ** not** required
241+ - Discovered containers automatically build and start during workspace
242+ initialization
243+ - The ` coder_devcontainer ` resource is not required
269244- Developers can work with multiple projects seamlessly
270245
271246> [ !NOTE]
272247>
273248> When using project discovery, you still need to install the devcontainers CLI
274249> using the module or in your base image.
275250
251+ ## Example Template
252+
253+ The [ Docker (Dev Containers)] ( https://github.com/coder/coder/tree/main/examples/templates/docker-devcontainer )
254+ starter template demonstrates Dev Containers integration using Docker-in-Docker.
255+ It includes the ` devcontainers-cli ` module, ` git-clone ` module, and the
256+ ` coder_devcontainer ` resource.
257+
276258## Next Steps
277259
278260- [ Dev Containers Integration] ( ../../../user-guides/devcontainers/index.md )
261+ - [ Customizing Dev Containers] ( ../../../user-guides/devcontainers/customizing-dev-containers.md )
279262- [ Working with Dev Containers] ( ../../../user-guides/devcontainers/working-with-dev-containers.md )
280263- [ Troubleshooting Dev Containers] ( ../../../user-guides/devcontainers/troubleshooting-dev-containers.md )
0 commit comments