[Bug]: sbx CI jobs fail on kit build, network policy and ExampleContainer_Host

Open
#4,096 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
docker, docker-compose, github-actions, go
Domain
backend, ci-cd, testing

Research direction

Start with the Test core using sbx workflow and the named failures: TestRealSandboxKits, internal/core.TestExtractDockerHost, and ExampleContainer_Host. Check how the workflow configures buildx and sandbox network policy, then compare the expected container host with the sbx runtime output. Done when these failures pass in the sbx jobs; the issue also mentions reaper race failures addressed by #3868.

Written by the indexing model from the issue text.

Description

bug
Testcontainers version

v0.46.0 (main, 3d48472a)

Using the latest Testcontainers version?

Yes

Host OS

Linux, GitHub Actions ubuntu-24.04 runners in the Test core using sbx jobs

Host arch

x86_64

Go version

1.26.10 and 1.27.3

Docker version

sbx v0.51.0 (docker-sbx 0.51.0-1~ubuntu.24.04~noble from Docker's apt repository), sandbox Engine 29.9.2

Docker info

Operating System: Docker Hardened Images/Debian GNU/Linux 13 (trixie) (containerized)

What happened?

The Test core using sbx jobs fail on main and on same-repository pull requests that touch the sbx paths, so the end check fails for them. They failed this way on main on 5 November (run 42075741888) and on #4095 (run 42373890168), both with sbx v0.51.0. At the #3987 merge on 25 October they failed earlier, on auth login failed: invalid Docker credentials. Most runs skip these jobs, so the failures have gone unnoticed.

Three of the failures come from the sbx environment rather than from the code under test.

TestRealSandboxKits fails to build its test kit, as the runner's buildx uses the docker driver, which doesn't support the OCI exporter the kit build needs.

internal/core.TestExtractDockerHost panics when the sbx provider creates its sandbox, as no global network policy has been initialized. The workflow runs sbx --app-name "$TESTCONTAINERS_SBX_APP_NAME" policy init allow-all, which appears to cover only that app name, while this sandbox is created without it. This is a hypothesis I haven't confirmed in the sbx module.

ExampleContainer_Host expects localhost as the container host, but under sbx it is 127.0.0.1, the runtime's published host.

The other failures in these jobs, TestGenericReusableContainerInSubprocess and TestReaper_ReuseRunning, are reaper races that sbx's slower container start makes likely, and are fixed by #3868.

Relevant log output
error: resolve kits: kit "./testdata/test-tools": build kit ./testdata/test-tools: exit status 1 ERROR: failed to build: OCI exporter is not supported for the docker driver. Switch to a different driver, or turn on the containerd image store, and try again. Learn more at https://docs.docker.com/go/build-exporters/
--- FAIL: TestRealSandboxKits

panic: initialize provider "sbx": sbx create: exit status 1: error: global network policy has not been initialized
FAIL internal/core.TestExtractDockerHost/Docker_Host_is_extracted_just_once

--- FAIL: ExampleContainer_Host
got:
127.0.0.1
true
want:
localhost
true
Additional information

@mdelapenya, as these came in with the sbx runtime provider in #3987, could you take a look? Pull requests from forks skip these jobs, so #3868 can't show its fix for the reaper races under sbx until it is rebased onto a branch in this repository.

Dominant language
Go
Stars
5k
Forks
660
Avg merge
3d 11h
Merged PRs (30d)
48

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

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.

More from testcontainers/testcontainers-go

All issues in testcontainers/testcontainers-go

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.