testcontainers-dotnet: InvalidOperationException `cannot hijack chunked ... stream` (Rancher Desktop, Docker Desktop 4.10.0)

Describe the bug Please see this bug reported by someone else in Docker DotNet: https://github.com/dotnet/Docker.DotNet/issues/554

My own response to this: https://github.com/dotnet/Docker.DotNet/issues/554#issuecomment-1064806276

To Reproduce Steps to reproduce the behavior:

  1. Use Rancher Desktop with WSL2 enabled and dockerd (moby)
  2. Run unit tests in dotnet-testcontainers solution (I am only focused on RabbitMq myself)
  3. Exception thrown

Expected behavior Unit test passes

Desktop (please complete the following information):

  • Rancher Desktop (Windows install) v1.1.1
  • Windows 10 with WSL2 Ubuntu

Workaround

  • Use snapshot release 2.1.0-beta.2698157448
  • Downgrade to Docker Desktop 4.9.x

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 5
  • Comments: 28 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Quick update because I know a couple of devs waiting for a fix. We’re trying to contact the maintainers. If that somehow won’t work we’ll fork and fix it.

Same on Docker Desktop for Mac (4.10.0) it seems, downgrading to 4.9.1 makes the error go away.

System.AggregateException : One or more errors occurred. (cannot hijack chunked or content length stream) (cannot hijack chunked or content length stream)
---- System.InvalidOperationException : cannot hijack chunked or content length stream
---- System.InvalidOperationException : cannot hijack chunked or content length stream
 Stack Trace:
----- Inner Stack Trace #1 (System.InvalidOperationException) -----
  at [Microsoft.Net](http://microsoft.net/).Http.Client.HttpConnectionResponseContent.HijackStream()
  at Docker.DotNet.DockerClient.MakeRequestForHijackedStreamAsync(IEnumerable`1 errorHandlers, HttpMethod method, String path, IQueryString queryString, IRequestContent body, IDictionary`2 headers, TimeSpan timeout, CancellationToken cancellationToken)
  at Docker.DotNet.ContainerOperations.AttachContainerAsync(String id, Boolean tty, ContainerAttachParameters parameters, CancellationToken cancellationToken)
  at DotNet.Testcontainers.Clients.DockerContainerOperations.AttachAsync(String id, IOutputConsumer outputConsumer, CancellationToken ct)
  at DotNet.Testcontainers.Containers.Modules.TestcontainersContainer.Start(String id, CancellationToken ct)
  at DotNet.Testcontainers.Containers.Modules.TestcontainersContainer.StartAsync(CancellationToken ct)```

I’ve emailed the @dotnet-foundation and asked if they can help us, or if I can get access to the repository. I prefer a fix in the upstream. A fork should be the last option.

Awesome 🥳 I’ll publish a release version later that day. Thanks for your response.

Just to update the group here – the maintainer responded and Docker.Dotnet has a new release that includes @HofmeisterAn’s fix.

So I think as soon as we get a new release of testcontainers-dotnet with the updated Docker.Dotnet dependency, we should be good.

I can confirm. It’s broken for Docker Desktop for Windows (4.10.0) too. We need a fix in https://github.com/dotnet/Docker.DotNet/issues/554.

@HofmeisterAn just coming across this. I also reached out to the .NET Foundation Maintainers committee on the Discord & Slack to see if pinging there might help move it along.

In a way, I’m relieved – was testing Testcontainers for the first time (LOVE the idea!) and thought I’d done something wrong 😅

Getting this bug as well after updating to 4.10.