Windows: Docker API ignores Connection: close, so a body-less 204 (container start) hangs Testcontainers for .NET

Open
#225 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
docker, rust

Research direction

Start by tracing how Kiri handles Docker Engine API requests over named pipes and how it writes HTTP responses for container start. Check whether the server honors the request's Connection: close header after sending a body-less 204 response. Reproduce with the PowerShell request in the issue; done when the client receives EOF after the 204.

Written by the indexing model from the issue text.

Description

Kiri version and system

Kiri 0.2.0 on Windows 11 Pro 10.0.26200 (x64), Docker API over \\.\pipe\kiri (also reached through \\.\pipe\docker_engine).

What you did

Sent Docker Engine API requests with the header Connection: close over the named pipe, as Docker.DotNet does on every request (it is the client under Testcontainers for .NET 4.11). Minimal repro in PowerShell, no Docker client involved:

$p = [IO.Pipes.NamedPipeClientStream]::new('.', 'kiri', [IO.Pipes.PipeDirection]::InOut); $p.Connect(3000)
$req = "POST /containers/<id>/start HTTP/1.1`r`nHost: docker`r`nConnection: close`r`nContent-Length: 0`r`n`r`n"
$b = [Text.Encoding]::ASCII.GetBytes($req); $p.Write($b, 0, $b.Length); $p.Flush()
# read until EOF, with a 5 s timeout

(<id> from a plain POST /containers/create with {"Image":"alpine:3.20","Cmd":["sleep","30"]}.)

What happened

Kiri answers, but never closes the connection. After 5 s the pipe is still open with no EOF:

HTTP/1.1 204 No Content
Api-Version: 1.47
Docker-Experimental: false
Ostype: linux
Server: Kiri/0.2.0 (linux)

The 204 carries neither Connection: close nor Content-Length. The 201 from create also stays open after its body; clients cope there because it carries a body length, but a body-less 204 leaves them waiting for the end of the response.

Effect: Testcontainers for .NET hangs forever right after POST /containers/{id}/start returns 204 (Docker.DotNet waits for the connection to end before it completes the response). A test run sat 16 minutes with no further API call.

What you expected instead

What dockerd does: when the request says Connection: close, the server closes the connection after sending the response (RFC 9112 §9.6), so the client sees EOF right after the 204.

Anything else
  • Happens every time.
  • Workaround: a small named-pipe relay in front of \\.\pipe\kiri that closes the client connection after a 204/304 response, with docker.host=npipe://./pipe/<relay> in ~/.testcontainers.properties. With that (plus rewriting "Cmd":[] to null, which is the separate #121 / #222 problem: Ryuk fails with 400 no command specified, and mcr.microsoft.com/mssql/server runs its entrypoint with no arguments and exits), Testcontainers for .NET with Ryuk enabled and SQL Server works on Kiri.
  • Related: #121, #222.
Dominant language
Rust
Stars
7.5k
Forks
329
Avg merge
7h 48m
Merged PRs (30d)
105

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from libracoder/kiri

All issues in libracoder/kiri

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.