Skip to content

[Bug]: SIGSEGV (Segmentation Fault) during Docker environment detection on OpenJDK 25 / Ubuntu 24.04 #11724

@arfawy

Description

@arfawy

Module

Core

Testcontainers version

1.20.4 (BOM) / 2.0.5 (Modules)

Using the latest Testcontainers version?

Yes

Host OS

Ubuntu 24.04 LTS

Host Arch

x86_64

Docker version

Client:
 Version:           29.1.3
 API version:       1.52
 Go version:        go1.24.4
 Git commit:        29.1.3-0ubuntu3~24.04.1
 Built:             Fri Mar  6 11:35:12 2026
 OS/Arch:           linux/amd64
 Context:           default

Server:
 Engine:
  Version:          29.1.3
  API version:      1.52 (minimum version 1.44)
  Go version:       go1.24.4
  Git commit:       29.1.3-0ubuntu3~24.04.1
  Built:            Fri Mar  6 11:35:12 2026
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          2.2.1
  GitCommit:
 runc:
  Version:          1.3.4-0ubuntu1~24.04.1
  GitCommit:
 docker-init:
  Version:          0.19.0
  GitCommit:

What happened?

[Bug] SIGSEGV (Segmentation Fault) during Docker environment detection on OpenJDK 25 / Ubuntu 24.04

Description

I am encountering a critical failure when starting Testcontainers on a modern Linux stack. The application throws java.lang.IllegalStateException: Could not find a valid Docker environment, but a system-level trace reveals that the JVM is actually crashing with a Segmentation Fault (SIGSEGV) immediately after successfully connecting to the Docker socket.

Environment

  • OS: Ubuntu 24.04 LTS
  • JDK: OpenJDK 25
  • Docker Engine: v29.x
  • Testcontainers Version: 1.20.4 (BOM) / 2.0.5 (Modules)

The "Smoking Gun" (Technical Proof)

I performed a strace -f on the JVM process to isolate the failure. The logs show that the connection to the Docker socket is established successfully, but is immediately followed by a native crash:

connect(..., {sa_family=AF_UNIX, sun_path="/var/run/docker.sock"}, ...) = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x14} ---

The si_addr=0x14 strongly suggests a null pointer dereference in the native transport layer (likely JNR or JNA) used by docker-java to communicate with the Docker daemon.

Attempted Workarounds (All failed)

To isolate the issue, I have already tried the following without success:

  • Socket Permissions: Set /var/run/docker.sock to chmod 666.
  • Environment Variables: Explicitly set DOCKER_HOST=unix:///var/run/docker.sock.
  • TCP Bypass: Configured Docker daemon to listen on TCP port 2375 and pointed DOCKER_HOST=tcp://localhost:2375. The crash still occurs.
  • API Version: Forced docker.api.version=1.44 in .testcontainers.properties.
  • JVM Flags: Added --enable-native-access=ALL-UNNAMED and --add-opens for java.base/java.util, java.base/java.lang, and java.base/java.nio to bypass Java 25's integrity restrictions.
  • Resource Reaper: Disabled Ryuk via TESTCONTAINERS_RYUK_DISABLED=true.

Expected Behavior

Testcontainers should be able to detect and connect to a functional Docker daemon on OpenJDK 25.

Actual Behavior

The JVM suffers a native segmentation fault during the environment discovery phase, leading to a generic "Could not find a valid Docker environment" exception.

Relevant log output

42147 connect(212<socket:[313085]>, {sa_family=AF_UNIX, sun_path="/var/run/docker.sock"}, 23) = 0
42147 connect(212<socket:[317725]>, {sa_family=AF_UNIX, sun_path="/var/run/docker.sock"}, 23) = 0
...
42147 --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x14} ---
42147 connect(214<socket:[317733]>, {sa_family=AF_UNIX, sun_path="/var/run/docker.sock"}, 23) = 0
42147 connect(214<socket:[317734]>, {sa_family=AF_UNIX, sun_path="/var/run/docker.sock"}, 23) = 0
...
42110 --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x8} ---

Additional Information

debug_testcontainers.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions