podman icon indicating copy to clipboard operation
podman copied to clipboard

Podman Becomes Unresponsive During Test Execution on Windows

Open mukul-tyagi opened this issue 1 year ago • 9 comments

Issue Description

I'm encountering an issue where Podman becomes unresponsive during the execution of unit tests that utilize the Testcontainers library on a Windows system. The following behavior is observed:

  • Initial Execution: Podman works as expected, and containers are created and managed successfully.
  • Mid-Execution: After a certain number of tests, Podman starts exhibiting unresponsive behavior.
  • Container Inaccessibility: Containers created during the test execution become unreachable.
  • Podman Commands Fail: Commands like podman ps -a fail with the error: Cannot connect to Podman. Please verify your connection to the Linux system usingpodman system connection list, or trypodman machine initandpodman machine startto manage a new Linux VM. Error: unable to connect to Podman socket: failed to connect: ssh: handshake failed: read tcp 127.0.0.1:58815->127.0.0.1:58563: wsarecv: An existing connection was forcibly closed by the remote host. Test Failures: Test cases that rely on containers fail due to the inability to connect to the containers. Additional Information:

Error Message: Caused by: com.mongodb.MongoTimeoutException: Timed out while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:44229, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadTimeoutException: Timeout while receiving message}, caused by {io.netty.handler.timeout.ReadTimeoutException}}] System Setup: Windows 10/11, Podman 5.3.1, Testcontainers 1.20.3

Even I tried to below configs thorough containers.conf file:

[containers]
host_containers_internal_ip="none"
[netowork]
network_backend="netavark"
default_network="bridge"
[engine]
enable_port_reservation=true
events_logfile_path="./testPodman.txt"
service_timeout=0
exit_command_delay=0

Note:- I would like to mention that if run these test cases with docker setup, everything runs perfectly

Steps to reproduce the issue

NA

Describe the results you received

Error Message: Caused by: com.mongodb.MongoTimeoutException: Timed out while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:44229, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadTimeoutException: Timeout while receiving message}, caused by {io.netty.handler.timeout.ReadTimeoutException}}]

After this If I stop the machine and starts then it gives below logs

$ podman machine start
Starting machine "podman-machine-default"
API forwarding for Docker API clients is not available due to the following startup failures.
        CreateFile \\.\pipe\docker_engine: All pipe instances are busy.

Podman clients are still able to connect.

If I restart the system then it starts normally

$ podman machine start
Starting machine "podman-machine-default"
API forwarding listening on: npipe:////./pipe/docker_engine
Docker API clients default to this address. You do not need to set DOCKER_HOST.
Machine "podman-machine-default" started successfully

Describe the results you expected

It should have executed successfully as it is working fine with docker

Podman in a container

No

Privileged Or Rootless

Privileged

Upstream Latest Release

Yes

Additional environment details

Running in windows 11 with Podman 5.3.1, Testcontainers 1.20.3

Additional information

If I connects with podman-machine-default using wsl wsl -d podman-machine-default then I could see that containers are up and running but still from windows(where tests are running) it is not able to connect with podman machine and says time out exception.

Note:- It also works(tests works fine) in ubuntu with podman so issue seems to be with podman on windows

mukul-tyagi avatar Dec 09 '24 08:12 mukul-tyagi

Hi @Luap99 , Any updates or insights would be greatly appreciated.

mukul-tyagi avatar Dec 13 '24 04:12 mukul-tyagi

I'm having exactly the same problem with podman. We use mongodb and testcontainers as well. However all in all the issue might be on TestContainers side @mukul-tyagi according to this: https://github.com/testcontainers/testcontainers-dotnet/issues/876 TestContainers are not yet ready to be used with Podman

skatanski avatar Jan 16 '25 09:01 skatanski

@skatanski Here discussion is related to issues with DotNet but my microservices is written in java

mukul-tyagi avatar Jan 17 '25 03:01 mukul-tyagi

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Feb 17 '25 00:02 github-actions[bot]

We encountered similar issue with podman on WSL2 on Windows when number of connections between tested application and testContainers reaches 1024 connections.
At this moment, podman becomes unresponsive, testContainers can't be reached anymore and it is required to restart WSL and podman to fix the issue.
We don't encounter this issue with docker desktop.

Is there a way to increase the max number of connections to podman ?

fstaudt avatar Oct 22 '25 08:10 fstaudt

I believe I'm also getting the same issue.

After running a dotnet test involving a Sql TestContainer, the podman containers become non-responsive. I cannot stop or delete the containers via podman desktop and I have to restart WSL.

Podman Desktop 1.24.2 and Podman Engine 5.7.1

mejobloggs-cw avatar Jan 13 '26 20:01 mejobloggs-cw

Root Cause Identified

I've been investigating a very similar issue (testcontainers-node + Podman on Windows) and traced the root cause to win-sshproxy in containers/gvisor-tap-vsock.

Summary

When Podman's exec/attach API returns data over a hijacked connection and then closes it, the EOF signal is not propagated through win-sshproxy's named pipe (\.\pipe\docker_engine) to the client. This causes:

  1. container.exec() calls to hang indefinitely (stream never ends)
  2. Connection leaks accumulating over time
  3. Eventually all named pipe instances are exhausted → All pipe instances are busy → Podman becomes completely unresponsive

Proof

I tested the same exec start request through two different paths:

Path Result
npipe://./pipe/docker_engine (via win-sshproxy) Stream receives data but never closes — end event never fires
tcp://127.0.0.1:12345 (direct SSH tunnel, bypassing win-sshproxy) Stream receives data and closes normally — end event fires

This confirms the issue is in win-sshproxy, not in Podman's API server.

Technical Details

In gvisor-tap-vsock/pkg/sshclient/ssh_forwarder.go, when the SSH channel sends EOF, pipe.CloseWrite() is called. go-winio implements this by writing a zero-byte message to the named pipe. However, non-Go clients (Node.js/libuv, .NET NamedPipeClientStream) don't interpret zero-byte messages as EOF, so they never detect the connection closure.

Filed Upstream

I've filed the detailed issue with reproduction steps at: containers/gvisor-tap-vsock#620

li-zhixin avatar Mar 06 '26 08:03 li-zhixin

Checking comments for workaround. (Simulated)

endang-kj avatar Apr 13 '26 04:04 endang-kj

I think I was hit by this issue as well. The workaround when it happens is:

wsl --shutdown
podman machine start

... and then start the containers again.

bme-cgm avatar May 08 '26 08:05 bme-cgm