testcontainers / testcontainers/testcontainers-java

[Containerd] IN_A_CONTAINER didn't set correctly in containers started up via containerd service

Open
#4,398 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
8.7k
Forks
1.9k
Avg merge
2d 17h
Merged PRs (30d)
9

Description

public static final boolean IN_A_CONTAINER = new File("/.dockerenv").exists();
testcontainers use '/.dockerenv' to decide if IN_A_CONTAINER is true or false.
But in the containers started by containerd, '/.dockerenv' does not exist, and it will lead to testcontainers to connect ryuk via localhost, and ryuk will failed to be connected.
Errors from maven log as below:

java.lang.IllegalStateException: Could not connect to Ryuk at localhost:49175

And the latest testcontainers 1.1.6.0 is used here.
Look forward to fixing for this.

Contributor guide

Open the contributing guide

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.

Research direction

Start by locating the declaration of IN_A_CONTAINER and the code that connects to Ryuk. Reproduce the localhost connection failure when containers are started through containerd, then inspect existing container-runtime tests if available. Done means containerd-started containers detect their environment correctly and the Ryuk connection succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, java
Domain
devops, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.