Skip to content

Add --docker-arg option for global Docker CLI arguments - #1304

Merged
Christof Marti (chrmarti) merged 3 commits into
devcontainers:mainfrom
shuaiyuanxx:user/shawn/wslc-debug-support-session-args
Oct 30, 2026
Merged

Christof Marti (chrmarti) merged 3 commits into
devcontainers:mainfrom
shuaiyuanxx:user/shawn/wslc-debug-support-session-args

Conversation

@shuaiyuanxx

@shuaiyuanxx Shawn Yuan (shuaiyuanxx) commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds an optional, repeatable --docker-arg option to every command that accepts --docker-path (up, set-up, build, run-user-commands, read-configuration, exec and upgrade). Each value is passed as a global argument before the subcommand of every Docker CLI invocation.

This enables Dev Containers to target existing WSLC SDK Sessions using wslc --session <name>. It also works for other global CLI options such as Docker's --context or Podman's --connection.

This PR needs to be used together with this dev container PR.

Changes

  • Preserve Docker arguments through setup, lifecycle commands, CLI probes, and internal exec/PTY operations, including Docker CLI parameters derived from resolver parameters.
  • Prefix the Docker Compose plugin (docker <args> compose ..., including the compose version probe), but not a standalone --docker-compose-path executable.
  • Keep existing behavior when the option is omitted.

Example

devcontainer set-up \
  --docker-path wslc \
  --docker-arg=--session \
  --docker-arg="SDK Session" \
  --container-id CONTAINER_ID

Validation

  • Focused tests, type checking, lint, and build passed.
  • Parsing is covered for all seven commands, as well as Compose plugin vs. standalone Compose prefixing.
  • Verified set-up and run-user-commands against an SDK-created container.
  • Verified missing-session rejection and VS Code attachment, terminal access, and reload with the paired extension.

Accept --docker-arg on every command that takes --docker-path (up, set-up,
build, run-user-commands, read-configuration, exec and upgrade) for consistency
with --docker-path. Prefix the Docker Compose plugin invocation
(docker <args> compose) but not a standalone docker-compose executable, and
keep the arguments on Docker CLI parameters derived from resolver parameters.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@chrmarti
Christof Marti (chrmarti) force-pushed the user/shawn/wslc-debug-support-session-args branch from 53a7124 to 7251b0a Compare October 30, 2026 11:37
@chrmarti Christof Marti (chrmarti) changed the title Support optional argument prefixes for container runtimes Add --docker-arg option for global Docker CLI arguments Oct 30, 2026
Run the built CLI with an unreachable DOCKER_HOST and the real endpoint passed
with --docker-arg=-H so any Docker invocation that drops the arguments fails.
Cover up, exec, set-up, run-user-commands, read-configuration, build and the
Docker Compose plugin. The tests use execFile without a shell, so they also run
on Windows.

Also include the Docker arguments when rewriting container exec log lines to
"Run in container:".

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@chrmarti
Christof Marti (chrmarti) merged commit a190a3f into devcontainers:main Oct 30, 2026
68 of 69 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants