Feature parity: CLI has no equivalent to the host-integration capabilities IDEs provide (port forwarding, browser opening, credential/file mounts)
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 活跃
- 技术栈
- docker, typescript
调研方向
Start by reading src/spec-node/singleContainer.ts and dockerCompose.ts, then trace forwardPorts and portsAttributes from src/spec-configuration/configuration.ts through mergeForwardPorts in src/spec-node/imageMetadata.ts. Done means reaching a maintainer decision on scope and splitting the three host-integration gaps into separate implementation or documentation issues.
由索引模型根据 Issue 内容生成。
描述
Why this matters
Teams standardizing on Dev Containers need the CLI path (devcontainer up /
devcontainer exec) to behave like the IDE path. A container definition that
works when opened in VS Code should work the same way under the CLI. Today it
doesn't for anything that depends on host↔container interactivity.
Without that parity, each CLI user ends up reproducing the IDE's behavior by
hand — working out per-platform socket paths, hand-writing mounts entries,
wiring up ad-hoc port publishing — or reaching for a non-standard alternative
tool. Either way, work that should live once in the shared container
definition gets pushed onto individual machines instead.
This issue is intentionally proposal-level: it names the pattern rather than
proposing a single implementable change. If the project agrees with the
premise, we'd expect it to be split into individual issues per use case for
actual implementation.
The gap
When an IDE (e.g. VS Code Remote - Containers) opens a Dev Container, it does a
significant amount of host integration work that makes the container feel
local:
- it forwards ports the container starts listening on back to the host,
- it provides a mechanism for processes in the container to open a URL in the
host's browser, - and it auto-mounts host files and sockets the container needs to act like
the host's environment — the SSH agent socket,~/.gitconfig,
~/.ssh/known_hosts, credential-helper state — without any of this being
declared indevcontainer.json.
It also manages the lifecycle of all of these bridges for as long as the
window is connected.
The Dev Containers CLI (@devcontainers/cli, devcontainer up / devcontainer exec) builds the container, applies declared mounts, propagates
containerEnv / remoteEnv, and runs the lifecycle commands — but it does
not provide equivalents for that host-integration layer. What exists is
limited and client-oriented:
appPortis published statically as-p 127.0.0.1:<port>:<port>at
container-create time. This only works for ports known ahead of time; it
cannot cover a port chosen at runtime inside the container.forwardPorts/portsAttributesare parsed and merged into the resolved
configuration, but the CLI takes no action on them.- The CLI emits
tunnelInformationdescribing already-published ports, for a
client to act on — it does not itself forward anything. mounts(and Feature-contributed mounts) are applied as static
--mount/compose-volume entries, exactly likeappPort— but only for
mounts the user explicitly declares. The CLI has no notion of "mount the
host's SSH agent socket" or "mount the host's git identity" the way VS
Code's extension does automatically; reproducing that today means manually
working out host-specific paths (Docker Desktop vs. OrbStack vs. Colima vs.
Linux all differ) and hand-writing the equivalentmountsentries yourself,
per machine.
There is no dynamic port forwarding (watching for newly-listening ports,
forwarding ephemeral ones, tearing down on disconnect), no host-browser
bridge, and no host-credential/file auto-mounting. That active layer lives
entirely in the IDE clients.
For workflows that only need to build and exec, this is fine. But for anything
that depends on host↔container interactivity — networking, browser-based auth,
or using the host's SSH/git identity inside the container — there is no
supported path to parity with the IDE experience, and no documented pattern
for achieving it.
Related existing issues
Pieces of this gap already have open issues, filed independently and without a
common frame:
- SSH agent forwarding: cli#441
— maintainers confirmed this is "part of the extension, not the CLI." known_hostsimport: cli#439- Global
~/.gitconfignot copied (only local config is): cli#787 - Dynamic / runtime mount support: cli#1110,
cli#601 - Port forwarding reference implementation: cli#22
(maintainers noted it "requires NodeJS inside the container") forwardPortsnot honored: cli#186- No
stop/downcommand: cli#386
This issue isn't meant to duplicate those — it's meant to name the pattern
they share (host-integration behavior VS Code's extension does implicitly,
that the CLI has no equivalent for) and ask for a single, coherent answer
about whether/how the CLI intends to address it, rather than resolving each
symptom in isolation.
Concrete scenario
A common failure case is a CLI tool, run inside the container, that performs a
browser-based OAuth login:
- The tool starts a temporary loopback callback server on
127.0.0.1:<random_port>inside the container. - It opens (or prints) an authorization URL for the user to complete in a
browser. - The identity provider redirects to
http://127.0.0.1:<port>/callback.
Under an IDE this "just works": the browser opens on the host, and the IDE has
already forwarded the container's 127.0.0.1:<port> to the host loopback, so
the callback reaches the listener.
Under devcontainer up (or a bare docker run the CLI wraps), neither piece is
present:
- The URL may open in the container's context, where there is no browser.
- Even if the user opens it on the host,
127.0.0.1:<port>on the host is not
the container's loopback, so the callback never reaches the listener
("connection refused").
The same class of gap affects any dev server, debugger, or webhook receiver that
expects the IDE's automatic port forwarding.
What IDEs do that the CLI doesn't
- Dynamic port forwarding — auto-forwarding ports the container begins
listening on, plus honoringforwardPorts/portsAttributes, and tearing
the forwards down on disconnect. - Host browser bridge — a mechanism (e.g. surfacing a helper as
$BROWSER)
so a URL "opened" inside the container is actually opened on the host. - Host file/socket auto-mounting — the SSH agent socket,
~/.gitconfig,
~/.ssh/known_hosts, and credential-helper state are mounted or copied in
automatically, without amountsentry, and adapted per-platform (the
socket path for Docker Desktop, OrbStack, and native Linux all differ).
Where this shows up in the source
References below are to @devcontainers/cli v0.88.0.
appPortis the only port setting that produces a runtime action — published
statically as-p 127.0.0.1:<port>:<port>inspawnDevContainer
(src/spec-node/singleContainer.ts).forwardPorts/portsAttributes/otherPortsAttributesare defined in the
config schema (src/spec-configuration/configuration.ts) and merged via
mergeForwardPorts(src/spec-node/imageMetadata.ts), butforwardPortsis
never read outside that merge — nothing forwards based on it.getTunnelInformation(src/spec-node/utils.ts) maps already-published
container.PortsintoenvironmentTunnelsmetadata on the resolver result
(consumed insingleContainer.ts/dockerCompose.ts), and only for local
containers. It reports published ports; it does not forward.- No host-browser handling is present — the source has no
openExternal,
$BROWSER, orxdg-openpath. mounts(src/spec-configuration/configuration.ts) — including
Feature-contributed mounts — are resolved into--mountargs in
spawnDevContainer(src/spec-node/singleContainer.ts) or compose volume
entries (src/spec-node/dockerCompose.ts), but only for entries present in
the resolved config. There is no built-in mount (or equivalent copy step)
for the SSH agent socket, host git identity,known_hosts, or credential
helpers — those must be declared by hand, and the correct host path is
platform-dependent (Docker Desktop vs. OrbStack vs. Colima vs. Linux), which
the CLI has no logic to resolve.
Ask
Since the goal is CLI/IDE parity, we'd like guidance and, ideally, first-class
support, on all three host-integration gaps (port forwarding, browser bridge,
credential/file mounts) at the proposal level — they share the same shape and
we think a single answer should cover them, rather than resolving each in
isolation as its own issue. If the project agrees with the premise, we expect
the following directions to become individual implementation issues split by
use case; here they're presented together for the proposal-level discussion,
roughly in order of preference:
- Build (a subset of) these into the CLI — e.g. an opt-in
devcontainer up --forward-ports ...and/or honoringforwardPorts; a
documented host-browser hook; and an opt-in flag or config surface that
mounts the host's SSH agent socket / git identity /known_hosts, with the
CLI resolving the correct host path per platform the way the VS Code
extension does. - A supported wrapper / extension point — a stable interface the CLI
exposes so a small host-side wrapper can implement forwarding,
browser-opening, and credential mounting without reimplementing container
orchestration. (Third-party tools like
cella already do this outside the
CLI, as a native-binary wrapper — evidence this is solvable without
requiring Node.js inside the container.) - Documentation — if this is intentionally out of scope for the CLI, a
canonical guide on how to reproduce the IDE's forwarding, browser, and
credential-mounting behavior arounddevcontainer up(e.g. recommended
dockerflags,socat/SSH patterns, per-platform socket paths) would
close the knowledge gap.
Questions for maintainers
- Is host integration (forwarding, browser, credential/file mounts)
considered in-scope for the CLI, or intentionally left to IDE clients? If
it's intentionally out of scope, is that documented anywhere we can link to
and close related issues against (441, 439, 787, 1110, 601, 22, 186)? - Is there an existing recommended pattern for the OAuth-loopback case above,
or for forwarding the host's SSH agent / git identity into a CLI-managed
container? - Would a
forwardPorts-honoring flag onup, or a flag to auto-mount the
host's SSH agent socket and git identity, be a welcome contribution?
Co-Authored-By: Claude Code
- 主要语言
- TypeScript
- 星标
- 3k
- 派生
- 461
- 平均合并
- 18 分钟
- 30 天内合并 PR
- 5
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
devcontainers/cli 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 92/100
devcontainers/cli#1203 ·
-
难度 1/5 1-3 小时 新手友好度 68/100
devcontainers/cli#1178 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 78/100
devcontainers/cli#1307 ·
-
难度 4/5 3-5 天 新手友好度 55/100
devcontainers/cli#1305 ·
-
难度 3/5 1-2 天 新手友好度 68/100
devcontainers/cli#1301 ·
查看 devcontainers/cli 的全部 Issue
相似的 Issue
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 1/5 1 小时以内 新手友好度 85/100
-
Mend: dependency security vulnerability untriaged
难度 2/5 1-3 小时 新手友好度 70/100