Files
coder/docs/workspaces/devcontainers/working-with-dev-containers.md
T
coder[bot] d91aa1bebd docs: replace may with can or might per the Vale spike review (#31878)
Replaces `may` with `can` (ability or permission) or `might`
(possibility), following
`word-choice.md#choose-words-that-have-one-meaning`. The Vale findings
spike review marked every `may` row valid.

- 247 lines in 110 files: 75 became `can` and 162 became `might`. The
rest are small rewordings, such as "may wish" becoming "might want".
- Applied the reviewer notes:
- `.style/content-guidelines.md`: "docs may be written ahead" is now
"you can write docs ahead", which also drops the passive voice.
- `admin/external-auth.md`: now "You can grant access to a subset of
repositories.", so the sentence doesn't end on a preposition.
- Also fixed a typo in `gcp-to-aws.md`: "may needed" is now "might
need".

## Left as-is

- **`admin/setup/configuration-reference.md` (7 lines):** this page is
generated from `codersdk` deployment options (`<!-- DO NOT EDIT |
GENERATED CONTENT -->`), so the fix belongs in the Go option
descriptions, followed by `make gen`.
- **Text that quotes the product:**
- `admin/monitoring/health-check.md:196` matches the derphealth message.
- The heading at `templates/troubleshooting.md:45`, the first "may" on
line 47, and the link on line 67 match the web terminal's "your
workspace may be incomplete" warning and its anchor.
- `admin/integrations/oauth2-provider/troubleshooting.md:269` quotes a
server error.

The changed files have no new findings from other rules.

---
AI-generated by Superblink on behalf of @nickvigilante.

---------

Co-authored-by: coder[bot] <137810501+coder[bot]@users.noreply.github.com>
2026-11-06 17:17:35 -05:00

145 lines
4.8 KiB
Markdown

---
title: Work with Dev Containers
---
The dev container integration appears in your Coder dashboard, providing a visual representation of the running environment:
![Two dev containers running as sub-agents in a Coder workspace](../../images/user-guides/devcontainers/devcontainer-running.png)_Dev containers appear as sub-agents with their own apps, SSH access, and port forwarding_
## SSH access
Each dev container has its own agent name, derived from the workspace folder (for example, `/home/coder/my-project` becomes `my-project`).
You can find agent names in your workspace dashboard, or see [Agent naming](./index.md#agent-naming) for details on how names are generated.
<a id="using-the-coder-cli"></a>
### Use the Coder CLI
The simplest way to SSH into a dev container is using `coder ssh` with the workspace and agent name:
```console
coder ssh <workspace>.<agent>
```
For example, to connect to a dev container with agent name `my-project` in workspace `my-workspace`:
```console
coder ssh my-workspace.my-project
```
To SSH into the main workspace agent instead of the dev container:
```console
coder ssh my-workspace
```
<a id="using-openssh-config-ssh"></a>
### Use OpenSSH (config-ssh)
You can also use standard OpenSSH tools after generating SSH config entries with `coder config-ssh`:
```console
coder config-ssh
```
This creates a wildcard SSH host entry that matches all your workspaces and their agents, including dev container sub-agents.
You can then connect using:
```console
ssh my-project.my-workspace.me.coder
```
The default hostname suffix is `.coder`.
If your organization uses a different suffix, adjust the hostname accordingly.
The suffix can be configured via [`coder config-ssh --hostname-suffix`](../../reference/cli/config-ssh.md) or by your deployment administrator.
This method works with any SSH client, IDE remote extensions, `rsync`, `scp`, and other tools that use SSH.
## Web terminal access
Once your workspace and dev container are running, you can use the web terminal in the Coder interface to execute commands directly inside the dev container.
![Coder web terminal with dev container](../../images/user-guides/devcontainers/devcontainer-web-terminal.png)
## IDE integration (VS Code)
You can open your dev container directly in VS Code by:
1. Selecting **Open in VS Code Desktop** from the dev container agent in the Coder web interface.
1. Using the Coder CLI:
```console
coder open vscode <workspace>.<agent>
```
For example:
```console
coder open vscode my-workspace.my-project
```
VS Code will automatically detect the dev container environment and connect appropriately.
While optimized for VS Code, other IDEs with dev container support might also work.
## Port forwarding
Since dev containers run as sub-agents, you can forward ports directly to them using standard Coder port forwarding:
```console
coder port-forward <workspace>.<agent> --tcp 8080
```
For example, to forward port 8080 from a dev container with agent name `my-project`:
```console
coder port-forward my-workspace.my-project --tcp 8080
```
This forwards port 8080 on your local machine directly to port 8080 in the dev container.
Coder also automatically detects ports opened inside the container.
<a id="exposing-ports-on-the-parent-workspace"></a>
### Expose ports on the parent workspace
If you need to expose dev container ports through the parent workspace agent (rather than the sub-agent), you can use the [`appPort`](https://containers.dev/implementors/json_reference/#image-specific) property in your `devcontainer.json`:
```json
{
"appPort": ["8080:8080", "4000:3000"]
}
```
This maps container ports to the parent workspace, which can then be forwarded using the main workspace agent.
## Dev container features
You can use standard [dev container features](https://containers.dev/features) in your `devcontainer.json` file.
Coder also maintains a [repository of features](https://github.com/coder/devcontainer-features) to enhance your development experience.
For example, the [code-server](https://github.com/coder/devcontainer-features/blob/main/src/code-server) feature from the [Coder features repository](https://github.com/coder/devcontainer-features):
```json
{
"features": {
"ghcr.io/coder/devcontainer-features/code-server:1": {
"port": 13337,
"host": "0.0.0.0"
}
}
}
```
<a id="rebuilding-dev-containers"></a>
## Rebuild dev containers
When you modify your `devcontainer.json`, you need to rebuild the container for changes to take effect.
Coder detects changes and shows an **Outdated** status next to the dev container.
![Dev container showing Outdated status with rebuild option](../../images/user-guides/devcontainers/devcontainer-outdated.png)_The Outdated indicator appears when changes to devcontainer.json are detected_
Select **Rebuild** to recreate your dev container with the updated configuration.