Skip to content

fix: Accept the npipe:////SERVER/pipe/NAME endpoint form - #137

Merged
HofmeisterAn merged 2 commits into
testcontainers:mainfrom
leo7martins:fix/135-npipe-uri-parsing
Nov 30, 2026
Merged

HofmeisterAn merged 2 commits into
testcontainers:mainfrom
leo7martins:fix/135-npipe-uri-parsing

Conversation

@leo7martins

Copy link
Copy Markdown

What was wrong

Docker documents the Windows DOCKER_HOST named pipe endpoint as npipe:////./pipe/NAME (e.g. npipe:////./pipe/docker_engine, equivalent to \\.\pipe\NAME), and Docker Desktop writes this form into its contexts. DockerHandlerFactory refused exactly this form with System.InvalidOperationException: The endpoint is not a npipe URI., so any tool passing a context endpoint on as DOCKER_HOST (including Testcontainers) broke, while the Docker CLI requires precisely this form.

Root cause

System.Uri parses npipe:////SERVER/pipe/NAME with an empty Uri.Host and a path whose segments do not match the three-segment layout (/, pipe/, NAME) that DockerHandlerFactory required. On .NET 10 the . server is additionally dropped from the segments as a dot segment, so the server cannot be recovered from Uri at all.

The fix

DockerHandlerFactory now reads the pipe server and pipe name (the \\SERVER\pipe\NAME components) via a new TryParsePipeEndpoint: the npipe://SERVER/pipe/NAME path is unchanged (localhost still maps to .), and for the documented npipe:////SERVER/pipe/NAME shape the components are read from the endpoint's original string. Malformed endpoints (missing/empty server or pipe name, multi-segment pipe names) still throw "The endpoint is not a npipe URI.".

How tested

Tests were run by an AI coding agent (no Docker daemon needed; these are pure URI-parsing unit tests) using a user-scoped .NET SDK 10.0.404:

  • Reproduced first: CreateHandler_AcceptsDockerDocumentedNamedPipeEndpoints failed for all three four-slash endpoints with The endpoint is not a npipe URI. before the fix (3 failed / 9 passed).
  • After the fix: focused validation class 20/20; full Docker.DotNet.TestsV2 suite 47/47 per TFM on net8.0, net9.0 and net10.0 (six tests that compare against the docker CLI were not run locally because it is not installed; they are unchanged and covered by CI). New coverage: acceptance of both forms, exact server/pipe-name extraction (., localhost, remote, case-insensitive), malformed-form rejection, and an end-to-end DOCKER_HOST=npipe:////./pipe/docker_engine → DockerConfig → named pipe transport test. All target frameworks (net8.0/net9.0/net10.0/netstandard2.0/netstandard2.1) build without errors, and dotnet format --verify-no-changes passes.

Fixes #135

This was written with help from an AI coding assistant.

leo7martins and others added 2 commits November 26, 2026 22:23
Docker documents the Windows named pipe endpoint for DOCKER_HOST as npipe:////SERVER/pipe/NAME, for example npipe:////./pipe/docker_engine (equivalent to \SERVER\pipe\NAME). System.Uri parses this form with an empty host and a path that does not match the three-segment layout the named pipe transport expects, so endpoints in this form were refused with "The endpoint is not a npipe URI.". Read the pipe server and pipe name from the endpoint's original string for this form, next to the existing npipe://SERVER/pipe/NAME parsing.
@HofmeisterAn HofmeisterAn added bug Something isn't working enhancement New feature or request labels Nov 30, 2026

@HofmeisterAn HofmeisterAn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@HofmeisterAn
HofmeisterAn merged commit 1b725ef into testcontainers:main Nov 30, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: npipe endpoint in Docker's own form (npipe:////./pipe/NAME) is refused with "The endpoint is not a npipe URI"

2 participants