Skip to content

Support connecting to the Docker daemon running under WSL Containers (wslc://) #1928

Closed

Description

@DavidTavoularis

Feature request

Add a new wslc:// docker host transport so the plugin can talk to the Docker daemon that ships with WSL Containers (wslc, available in WSL 2.9.x and later, see https://learn.microsoft.com/windows/wsl/wsl-container).
Benefits: no more need to install podman or docker, only WSL !

Problem

Unlike Docker Desktop or Podman, WSL Containers exposes neither a Windows named pipe (//./pipe/docker_engine) nor a TCP port on the host. The Docker daemon runs inside the wslc virtual machine and is only reachable through a stdio bridge:

wslc system session run docker system dial-stdio

As a result, docker-maven-plugin cannot auto-detect or connect to a WSL Containers daemon today. On such a machine the connection detector falls through all existing providers and fails with:

No <dockerHost> given, no DOCKER_HOST environment variable,
no read/writable '/var/run/docker.sock' or '//./pipe/docker_engine' ...

Proposed solution

Introduce a wslc:// scheme, analogous to how DOCKER_HOST=ssh:// works: the transport spawns the bridge command above and lets Apache HttpClient drive its stdin/stdout as if it were an ordinary socket (one bridge process per HTTP connection, reused across requests via HTTP keep-alive).
Concretely:

  1. New transport (wslc://) built on the existing
    AbstractNativeClientBuilder / AbstractNativeSocketFactory abstractions (same pattern as the unix:// and npipe:// transports). A process-backed Socket bridges HttpClient to docker system dial-stdio.
  2. Auto-detection: add a Windows-only provider that selects wslc:// when the wslc CLI is present. Priority is placed below the Docker/Podman named pipe, so an existing Docker Desktop / Podman endpoint always wins and wslc is only used as a fallback. New discovery order:
    1. explicit dockerHost
    2. DOCKER_HOST env var
    3. /var/run/docker.sock (Unix)
    4. //./pipe/docker_engine (Windows named pipe)
    5. wslc:// if the wslc CLI is available (Windows) ← new
  3. Executable override: the wslc executable can be pointed at a non-default location via the WSLC_EXECUTABLE environment variable (kept out of the URL so Windows paths with spaces/backslashes don't have to survive URI parsing).

Notes / trade-offs

  • Auto-detection probes with wslc version (a cheap metadata call that does not start the container VM). It only checks that the CLI is present, so if wslc is installed but no session/daemon is ready, wslc is still selected and the failure surfaces as a connection error at build time.
  • Like the named-pipe transport, the process-backed socket has no socket-level read timeout; a hung daemon blocks the read until the bridge process ends.
  • There is an open change request against WSL itself microsoft/wsl#40976 that, if implemented, would have WSL Containers expose the Docker daemon through a host-visible endpoint (e.g. a Windows named pipe or TCP port) natively.
    If/when that lands, the wslc:// stdio-bridge proposed here becomes largely redundant: the daemon would be reachable through the plugin's existing npipe:// (or tcp://) transport and would be picked up by the current named-pipe auto-detection with no wslc-specific code path. In other words, this feature fills a gap that exists in today's wslc releases; its usefulness will diminish once WSL provides a native endpoint.

PR

I have a working implementation (new wslc:// transport + auto-detection + unit tests + docs), PR assisted with Claude Code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions