[Feature Request] Support DOCKER_HOST via Docker Engine API-compatible endpoint in WSLC
Description
WSLC (WSL Container) currently operates only through its own CLI (wslc.exe) and API (Microsoft.WSL.Containers NuGet package). There is no way for tools that expect the Docker Engine API (via the DOCKER_HOST environment variable) to connect to WSLC. This prevents using WSLC as a drop-in replacement for Docker Desktop.
Many tools in the container ecosystem rely on DOCKER_HOST / Docker Engine API, including:
- nektos/act — run GitHub Actions locally
- docker CLI — the standard Docker client
- Docker Compose — multi-container orchestration
- Testcontainers — integration testing with containers
- Podman (with podman.socket) — already exposes a Docker-compatible API
- buildx / buildkit — advanced image building
Current Workaround
Users must keep Docker Desktop installed alongside WSLC, defeating the purpose of a built-in container runtime. For example, running ct locally requires Docker Desktop's socket (//./pipe/docker_engine). There is no way to point DOCKER_HOST at a WSLC endpoint.
Proposed Solution
Add a Docker Engine API-compatible endpoint to WSLC, configurable in settings.yaml. Similar to how Podman exposes podman.socket:
`yaml
settings.yaml
session: cpuCount: default memorySize: default
New: Docker-compatible API endpoint
docker: socket: true # Enable Docker-compatible socket socketPath: "//./pipe/wslc_docker" # Windows named pipe (default)
or
tcp: "127.0.0.1:2375" # TCP endpoint (optional) `
Then users could set:
`powershell = "npipe:////./pipe/wslc_docker"
or
= "tcp://127.0.0.1:2375" `
And tools like ct, docker, compose would work transparently.
Environment
- WSLC version: Latest (Preview)
- Windows version: Windows 11
- Use case: Running ektos/act for local CI testing, replacing Docker Desktop
Additional Context
Both Podman and Docker Desktop already support this pattern. Adding Docker Engine API compatibility to WSLC would make it a true Docker Desktop alternative and significantly broaden its adoption in the development ecosystem.
Logs are required for review from WSL team
If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.
How to collect WSL logs
Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1
The script will output the path of the log file once done.
If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues
Once completed please upload the output files to this GitHub issue.
See Collect WSL logs (recommended method).
If you choose to email these logs instead of attaching them to the bug, please send them to [email protected] with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.
/feature
Diagnostic information
Found '/feature', adding tag 'feature'
Supporting this request, with a suggestion about the shape it should take — because I think "expose a socket" understates it, and the naive version is probably what is blocking a reply.
I posted the measurements behind this in #40948, so briefly: every wslc session already runs stock Moby (dockerd 25.0.3 / API 1.44) on /var/run/docker.sock, started with no -H, so the API is complete and simply has no listener reachable from Windows.
@DavidTavoularis got to the heart of it in #40957: wslc has two container planes, and only the native one (wslc run / the Container API) has the Windows integration. My results line up with his and sharpen one point. He reported 500 invalid volume specification for bind mounts over the Docker API; that is specific to Windows paths, which dockerd cannot interpret. Guest-absolute sources work normally over the socket — -v /var/run/docker.sock:/var/run/docker.sock yields a real socket in the container (srw-rw----), recorded unrewritten. So the Docker-API plane is missing the translation, not the capability. I can also confirm his port finding independently: published through the engine socket, a port is unreachable from Windows on every address; published via wslc run -p, a Windows-side listener appears and works.
Which is why the ask is four things, not one. An endpoint on its own would still fail Compose and Testcontainers on day one:
- The endpoint — a named pipe is the natural Windows spelling; TCP opt-in only.
- Host-path translation on the Docker-API plane — the VirtioFs share creation
wslc run -valready performs. - The port relay on the same plane — the VirtioNet relay
wslc run -palready performs. Without itgetMappedPort()fails and Testcontainers is unusable no matter how good the endpoint is. - Policy parity — which I suspect is the actual blocker, and the part worth the most detail.
On policy. The registry allowlist, Group Policy/Intune controls and the plugin hooks (ContainerStarted, ImageCreated) are all enforced in wslcsession.exe in front of dockerd. A relayed socket bypasses all three, and an admin who deployed a registry allowlist would be right to call that a regression. Shipping that would undercut the enterprise story that makes wslc interesting in the first place — so "just expose it" deserves the no it has been getting.
The gate is smaller than it sounds, though, because the traffic worth inspecting is narrow:
| request | gate |
|---|---|
POST /images/create |
registry allowlist, same check as the CLI path |
POST /containers/create, /start |
resource and privilege policy, plus the ContainerStarted hook |
POST /build |
whatever /run/wsl/buildkit-policy.json is meant to cover |
| everything else | relay untouched — inspect, logs, attach, stats, events need no gate |
Plus the obvious rails: off by default, enabled per session, Group-Policy controllable, and refusing to enable when a configured policy is not yet covered by the gate. That is a smaller change than a policy-free endpoint, and a considerably easier one to defend internally.
If a preview of any of this appears, I have the client side and a test matrix already wired — Compose, Testcontainers with Ryuk, buildx, Dev Containers, act — and would gladly run it against them, policy cases included, and report back.
One more requirement for the endpoint, found the hard way: session idle accounting would need to count containers created through it, or the endpoint would lose work on day one.
Today the session VM's lifetime is driven by an activity refcount — WSLCIdleState.h: "A single activity refcount is the only source of truth for 'the VM is needed'" — and containers hold that reference through their WSLCContainerImpl wrapper (UpdateActivityHoldLockHeld, held exactly while the container is Running). That is deliberate and it works: it is what keeps a detached wslc run -d alive after the CLI exits.
A container created directly on the engine socket has no wrapper, so it takes no reference. Measured on 2.9.11.0, same host, same fresh default VM, 80 s with no CLI activity:
| created with | after 80 s |
|---|---|
wslc run -d |
still running |
POST /containers/create + /start on /var/run/docker.sock |
exited 137, VM rebooted |
To be clear, that is not a bug today — the Docker-API plane is not a supported interface, nothing asked WSLC for the VM, and reclaiming it is correct. I am only flagging it because an endpoint turns that unsupported path into a supported one, and the accounting would have to follow. A user whose docker compose up is killed thirty seconds later because they stepped away would reasonably call that broken.
The good news is it looks small, on machinery that already exists: DockerEventTracker is already subscribed to Start / Stop / Exit / Destroy for the session's engine. Today it syncs the state of containers WSLC already knows about; an endpoint would want an untracked start to take an activity reference and die/destroy to release it.
Worth adding that the platform already handles the neighbouring case well: WSLCProcess.h's keep-alive token exists precisely because "a root-namespace process is not tracked as a container", and it holds an activity reference for as long as the client keeps the process alive. That mechanism is what makes the prototype workable in the meantime, and it suggests the container case would fit the same shape.
Third and last note from me on this, now that the prototype is finished rather than sketched. Everything below is a requirement I hit in practice, so the list is what a first-party endpoint would have to handle rather than what I imagine it might.
Setup: an external process serves \\.\pipe\docker_engine, relays to
/var/run/docker.sock inside the session VM over AF_HYPERV, and stock
docker.exe drives it. Compose, Testcontainers (Ryuk included) and buildx all
work. WSL 2.9.11.0, engine 25.0.3 / API 1.44.
Four things the endpoint would have to do, which a socket alone does not
1. Publish ports to Windows. dockerd binds inside the session VM, and the
relay that carries a port to the host is driven from the Windows side. An
endpoint that only forwards the API gives you containers whose -p maps to
nothing reachable. I had to watch /events and open a host listener per
mapping. Worth deciding deliberately whether the endpoint binds 127.0.0.1 (as
wslc run -p does today) or honours the address in PortBindings — I found the
latter much less surprising.
2. Keep the session alive while the endpoint is in use. Covered in my previous comment: the activity refcount does not count containers created through the Docker API, so a session idle-terminates under live work. I worked around it by holding a root-namespace process, which takes the same reference a container does. A first-party endpoint would presumably just take the reference.
3. Preserve the registry policy. This is the important one, and the reason I
think "just expose dockerd" would be wrong. WSLContainerRegistryAllowlist and
AllowWSLContainerPrivileged are enforced in wslcsession, in front of the
daemon; a raw socket bypasses them entirely. I mirrored the checks at the pipe —
reading the same HKLM\Software\Policies\WSL — and with an allowlist deployed
both paths now agree: wslc pull busybox gives
WSLC_E_REGISTRY_BLOCKED_BY_POLICY, and so does the same pull through the
endpoint.
Two details that cost me real time, in case they are useful on your side:
- Builds cannot be judged at the API perimeter. buildx has been the default
docker buildsince Docker 23 and never touchesPOST /build— it opens a session and hijacksPOST /grpc. Gating only/buildgates nothing a user hits.wslc image buildhandles this properly by attaching a BuildKit source policy to the solve request, which fails a blocked base image withsource "docker-image://docker.io/library/busybox:latest" denied by policy. That policy is client-side: a build sent straight to the session'sdockerdinherits none of it. So an endpoint would need to inject the same source policy, or refuse builds. wslpolicies.hand the shipped CLI disagree. The header says a caller "that cannot attribute traffic to a specific registry ... must therefore refuse the operation whenever any allowlist restriction is active", namingwslc image build. The shipped CLI is better than that and enforces per source instead. Worth reconciling the comment, since it is the natural specification for anyone implementing a second caller.
4. Decide what --platform means. The daemon selects and pulls a requested
platform happily, but there is no qemu/binfmt, so execution fails with exec format error and a buildx --platform build dies at the first RUN. A pull
that succeeds and a run that cannot is a confusing pair; an endpoint might
reasonably reject the foreign platform at pull time.
One measurement, because it bears on whether this is worth doing
With a wslc session and an upstream dockerd distro behind the same pipe, same
client, n=10 medians: docker version 69 vs 74 ms, ps 59 vs 59, run --rm busybox true 505 vs 527, exec 121 vs 135 ms. The engine inside a session is
not slower — there is no performance argument against exposing it.
Why I would still rather this were first-party
What I have is a workaround that depends on an unsupported plane. It re-implements your policy checks, which means it can drift from them; I would rather it did not exist. Gating the endpoint behind the same policy layer your CLI already uses makes every Docker tool work on WSL containers, and makes third-party bridges like mine pointless — which is the right outcome.
Implementation and the full measurement set, if anything above is worth checking: https://github.com/wslkit/skrog (Apache-2.0), write-up at https://wslkit.github.io/skrog/wslc-backend/.
I put together a POC to expose the WSLc DOCKER_HOST, so docker CLI can be used, including native docker compose. The tricks and current limitations are in the ps1 file. Feel free to try it out in hack it further. wsl-docker-api
For anyone blocked on the "Docker Compose" part of this request in the meantime: I maintain wslc-compose, a small open-source (MIT) CLI that drives wslc directly from an existing compose.yaml / docker-compose.yml, without needing a Docker-compatible endpoint. It is a stop-gap, not a substitute for the API endpoint requested here (it does not help act, Testcontainers, buildx, etc.).
It is now on PyPI (0.3.0):
pipx install "wslc-compose==0.*" # or: uv tool install / pip install
wslc compose up -d # or: wslc-compose up -d
Currently supported: networks (multi-network, IPv4 IPAM, static addresses, aliases), named volumes and bind mounts (Windows path translation), depends_on ordering, include, several -f files / COMPOSE_FILE, file-backed secrets/configs, scaling, config-drift detection, and extra_hosts: host-gateway for published ports. There is no daemon and no state file, and --dry-run prints the exact wslc commands. It was tested against wslc 3.0.3.
- PyPI: https://pypi.org/project/wslc-compose/
- Source / docs: https://github.com/bacarndiaye/wslc-compose
Bug reports and PRs are welcome. It would also help to know which compose features people need most while waiting for native support or an API endpoint.