Skip to content

[Bug]: Client fail to connect to Ryuk with keepAlive socket #1670

@Angelinsky7

Description

@Angelinsky7

Testcontainers version

4.11.0

Using the latest Testcontainers version?

Yes

Host OS

Linux (debian), Gitlab runner, docker dind

Host arch

x64

.NET version

9

Docker version

Client: Docker Engine - Community
 Version:           29.3.0
 API version:       1.54
 Go version:        go1.25.7
 Git commit:        5927d80
 Built:             Thu Mar  5 14:30:26 2026
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          29.3.0
  API version:      1.54 (minimum version 1.40)
  Go version:       go1.25.7
  Git commit:       83bca51
  Built:            Thu Mar  5 14:26:34 2026
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v2.2.2
  GitCommit:        301b2dac98f15c27117da5c8af12118a041a31d9
 runc:
  Version:          1.3.4
  GitCommit:        v1.3.4-0-gd6d73eb8
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Docker info

Client: Docker Engine - Community
 Version:    29.3.0
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.31.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v5.1.0
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 1
  Running: 0
  Paused: 0
  Stopped: 1
 Images: 7
 Server Version: 29.3.0
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 301b2dac98f15c27117da5c8af12118a041a31d9
 runc version: v1.3.4-0-gd6d73eb8
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.14.0-503.23.2.el9_5.x86_64
 Operating System: AlmaLinux 9.7 (Moss Jungle Cat)
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 7.503GiB
 Name: SRVARRCON1R.cg62.int
 ID: d2c9c732-b007-4f48-b257-9c249009801e
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
  ::1/128
 Live Restore Enabled: false
 Firewall Backend: iptables

What happened?

i think it related to #1666 even if I don't have any proxy but i'm in a gitlab-ci with docker-in-docker.

Since 4.11.0 I'm unable to make the ryuk image create containers. If I downgrade to 4.10, it works nicely.

is there something i forgot to configure with the change in 4.11.0 ?

sorry if this is not the correct place to add this, but i had the impression that maybe it's the same kind of issue even if i don't use a proxy or a private registry.

i i can give you more logs to help me resolve this issue, i'll be happy to help.

Relevant log output

with testcontainer-dotnet:4.10.0 everything is working as expected:

Test Framework Informational Messages: 
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v3.1.5+1b188a7b0a (64-bit .NET 9.0.14) 
[xUnit.net 00:00:00.13] Discovering: Tests.IntegrationTests 
[xUnit.net 00:00:00.25] Discovered: Tests.IntegrationTests 
[xUnit.net 00:00:00.35] Starting: Tests.IntegrationTests 
[testcontainers.org 00:00:00.31] Connected to Docker: Host: tcp://dind:2375/ Server Version: 29.3.0 Kernel Version: 6.1.0-31-amd64 API Version: 1.54 Operating System: Alpine Linux v3.23 (containerized) Total Memory: 7.75 GB 
[testcontainers.org 00:00:00.38] Searching Docker registry credential in CredsStore 
[testcontainers.org 00:00:00.38] Searching Docker registry credential in CredHelpers 
[testcontainers.org 00:00:00.38] Searching Docker registry credential in Auths 
[testcontainers.org 00:00:00.38] Searching Docker registry credential in Auths 
[testcontainers.org 00:00:00.38] Docker registry credential https://index.docker.io/v1/ not found 
[testcontainers.org 00:00:02.45] Docker image testcontainers/ryuk:0.14.0 created 
[testcontainers.org 00:00:02.89] Docker container e8d3fd9fdfa0 created 
[testcontainers.org 00:00:02.94] Start Docker container e8d3fd9fdfa0 
[testcontainers.org 00:00:03.27] Wait for Docker container e8d3fd9fdfa0 to complete readiness checks 
[testcontainers.org 00:00:03.27] Docker container e8d3fd9fdfa0 ready 
[testcontainers.org 00:00:17.63] Docker image postgres:latest created 
[testcontainers.org 00:00:21.36] Docker container ccfd6430a196 created 
[testcontainers.org 00:00:21.36] Start Docker container ccfd6430a196 
[testcontainers.org 00:00:21.72] Wait for Docker container ccfd6430a196 to complete readiness checks 
[testcontainers.org 00:00:21.73] Execute "pg_isready --host localhost --dbname test --username test" at Docker container ccfd6430a196 
[testcontainers.org 00:00:22.90] Execute "pg_isready --host localhost --dbname test --username test" at Docker container ccfd6430a196 
[testcontainers.org 00:00:24.15] Execute "pg_isready --host localhost --dbname test --username test" at Docker container ccfd6430a196 
[testcontainers.org 00:00:25.27] Execute "pg_isready --host localhost --dbname test --username test" at Docker container ccfd6430a196 
[testcontainers.org 00:00:25.37] Docker container ccfd6430a196 ready

but in testcontainer-dotnet:4.11.0

Test Framework Informational Messages: 
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v3.1.5+1b188a7b0a (64-bit .NET 9.0.14) 
[xUnit.net 00:00:00.14] Discovering: Tests.IntegrationTests 
[xUnit.net 00:00:00.27] Discovered: Tests.IntegrationTests 
[xUnit.net 00:00:00.36] Starting: Tests.IntegrationTests 
[testcontainers.org 00:00:00.62] Connected to Docker: Host: tcp://dind:2375/ Server Version: 29.3.0 Kernel Version: 6.1.0-31-amd64 API Version: 1.54 Operating System: Alpine Linux v3.23 (containerized) Total Memory: 7.75 GB 
[testcontainers.org 00:00:00.69] Searching Docker registry credential in CredHelpers 
[testcontainers.org 00:00:00.69] Searching Docker registry credential in Auths 
[testcontainers.org 00:00:00.69] Searching Docker registry credential in CredsStore 
[testcontainers.org 00:00:00.69] Searching Docker registry credential in Auths 
[testcontainers.org 00:00:00.69] Docker registry credential https://index.docker.io/v1/ not found 
[testcontainers.org 00:00:02.68] Docker image testcontainers/ryuk:0.14.0@sha256:7c1a8a9a47c780ed0f983770a662f80deb115d95cce3e2daa3d12115b8cd28f0 created 
[testcontainers.org 00:00:02.98] Docker container 2d13766b8f46 created 
[testcontainers.org 00:00:03.03] Start Docker container 2d13766b8f46 
[testcontainers.org 00:00:03.55] Wait for Docker container 2d13766b8f46 to complete readiness checks 
[testcontainers.org 00:00:04.59] Docker container 2d13766b8f46 ready 
[xUnit.net 00:01:05.21] DotNet.Testcontainers.Containers.ResourceReaperException : Initialization has been cancelled. 
[xUnit.net 00:01:05.21] Stack Trace: 
[xUnit.net 00:01:05.21] /_/src/Testcontainers/Containers/ResourceReaper.cs(243,0): at DotNet.Testcontainers.Containers.ResourceReaper.GetAndStartNewAsync(Guid sessionId, IDockerEndpointAuthenticationConfiguration dockerEndpointAuthConfig, IImage resourceReaperImage, IMount dockerSocket, ILogger logger, Boolean requiresPrivilegedMode, TimeSpan initTimeout, CancellationToken ct) 
[xUnit.net 00:01:05.21] /_/src/Testcontainers/Containers/ResourceReaper.cs(255,0): at DotNet.Testcontainers.Containers.ResourceReaper.GetAndStartNewAsync(Guid sessionId, IDockerEndpointAuthenticationConfiguration dockerEndpointAuthConfig, IImage resourceReaperImage, IMount dockerSocket, ILogger logger, Boolean requiresPrivilegedMode, TimeSpan initTimeout, CancellationToken ct) 
[xUnit.net 00:01:05.21] /_/src/Testcontainers/Containers/ResourceReaper.cs(142,0): at DotNet.Testcontainers.Containers.ResourceReaper.GetAndStartDefaultAsync(IDockerEndpointAuthenticationConfiguration dockerEndpointAuthConfig, ILogger logger, Boolean isWindowsEngineEnabled, CancellationToken ct) 
[xUnit.net 00:01:05.21] /_/src/Testcontainers/Clients/TestcontainersClient.cs(321,0): at DotNet.Testcontainers.Clients.TestcontainersClient.RunAsync(IContainerConfiguration configuration, CancellationToken ct) 
[xUnit.net 00:01:05.21] /_/src/Testcontainers/Containers/DockerContainer.cs(517,0): at DotNet.Testcontainers.Containers.DockerContainer.UnsafeCreateAsync(CancellationToken ct) 
[xUnit.net 00:01:05.21] /_/src/Testcontainers/Containers/DockerContainer.cs(339,0): at DotNet.Testcontainers.Containers.DockerContainer.StartAsync(CancellationToken ct) 
[xUnit.net 00:01:05.21] /builds/app/tests/Tests.IntegrationTests/Fixtures/IntegrationTestFactory.cs(28,0): at Tests.IntegrationTests.Fixtures.IntegrationTestFactory.InitializeAsync() 
[xUnit.net 00:01:05.23] DotNet.Testcontainers.Containers.ResourceReaperException : Initialization has been cancelled. 
[xUnit.net 00:01:05.23] Stack Trace: 
[xUnit.net 00:01:05.23] /_/src/Testcontainers/Containers/ResourceReaper.cs(243,0): at DotNet.Testcontainers.Containers.ResourceReaper.GetAndStartNewAsync(Guid sessionId, IDockerEndpointAuthenticationConfiguration dockerEndpointAuthConfig, IImage resourceReaperImage, IMount dockerSocket, ILogger logger, Boolean requiresPrivilegedMode, TimeSpan initTimeout, CancellationToken ct)

from what i can see the only difference is the @sha256:7c1a8a9a47c780ed0f983770a662f80deb115d95cce3e2daa3d12115b8cd28f0 the ryuk container is correctly created and running in both case:

d26bc8189de4   testcontainers/ryuk:0.14.0   "/bin/ryuk"   2 minutes ago   Up 2 minutes   0.0.0.0:32768->8080/tcp, [::]:32768->8080/tcp   testcontainers-ryuk-bb947e94-70bf-45f0-b599-b3f97872a294

time=2026-03-23T10:50:16.598Z level=INFO msg=starting connection_timeout=1m0s reconnection_timeout=10s request_timeout=10s shutdown_timeout=10m0s remove_retries=10 retry_offset=-1s changes_retry_interval=1s port=8080 verbose=false
time=2026-03-23T10:50:16.598Z level=INFO msg=Started address=[::]:8080
time=2026-03-23T10:50:16.598Z level=INFO msg="client processing started"
time=2026-03-23T10:50:18.430Z level=INFO msg="client connected" address=172.17.0.3:40174 clients=1
time=2026-03-23T10:50:18.431Z level=INFO msg="adding filter" type=label values="[org.testcontainers.resource-reaper-session=bb947e94-70bf-45f0-b599-b3f97872a294]"
time=2026-03-23T10:52:21.570Z level=ERROR msg=scan address=172.17.0.3:40174 error="read tcp 172.18.0.2:8080->172.17.0.3:40174: read: connection reset by peer"
time=2026-03-23T10:52:21.570Z level=INFO msg="client disconnected" address=172.17.0.3:40174 clients=0

but in the case of 4.11.0:

4c8379c890ce   testcontainers/ryuk:0.14.0   "/bin/ryuk"   5 seconds ago   Up 4 seconds   0.0.0.0:32768->8080/tcp, [::]:32768->8080/tcp   testcontainers-ryuk-047be254-a766-4552-bb27-350c7c697034

time=2026-03-23T10:55:57.153Z level=INFO msg=starting connection_timeout=1m0s reconnection_timeout=10s request_timeout=10s shutdown_timeout=10m0s remove_retries=10 retry_offset=-1s changes_retry_interval=1s port=8080 verbose=false
time=2026-03-23T10:55:57.153Z level=INFO msg=Started address=[::]:8080
time=2026-03-23T10:55:57.153Z level=INFO msg="client processing started"
time=2026-03-23T10:56:57.182Z level=INFO msg="prune check" clients=0
time=2026-03-23T10:56:57.182Z level=INFO msg="client processing stopped"
time=2026-03-23T10:56:57.182Z level=INFO msg=removed containers=0 networks=0 volumes=0 images=0
time=2026-03-23T10:56:57.182Z level=INFO msg=done

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions