Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Unable to connect to container #1782

Closed
itziklavon opened this issue Oct 19, 2023 · 42 comments
Closed

[Bug]: Unable to connect to container #1782

itziklavon opened this issue Oct 19, 2023 · 42 comments
Labels
bug An issue with the library

Comments

@itziklavon
Copy link

Testcontainers version

0.25.0

Using the latest Testcontainers version?

Yes

Host OS

Linux, MacOS

Host arch

x86, Arm

Go version

1.21

Docker version

Client:
 Cloud integration: v1.0.35+desktop.5
 Version:           24.0.6
 API version:       1.43
 Go version:        go1.20.7
 Git commit:        ed223bc
 Built:             Mon Sep  4 12:28:49 2023
 OS/Arch:           darwin/arm64
 Context:           default

Docker info

Client:
 Version:    24.0.6
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.2-desktop.5
    Path:     /Users/itziklavon/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.22.0-desktop.2
    Path:     /Users/itziklavon/.docker/cli-plugins/docker-compose
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     /Users/itziklavon/.docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.20
    Path:     /Users/itziklavon/.docker/cli-plugins/docker-extension
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v0.1.0-beta.8
    Path:     /Users/itziklavon/.docker/cli-plugins/docker-init
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /Users/itziklavon/.docker/cli-plugins/docker-sbom
  scan: Docker Scan (Docker Inc.)
    Version:  v0.26.0
    Path:     /Users/itziklavon/.docker/cli-plugins/docker-scan
  scout: Docker Scout (Docker Inc.)
    Version:  v1.0.7
    Path:     /Users/itziklavon/.docker/cli-plugins/docker-scout

Server:
 Containers: 1
  Running: 0
  Paused: 0
  Stopped: 1
 Images: 83
 Server Version: 24.0.6
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 8165feabfdfe38c65b599c4993d227328c231fca
 runc version: v1.1.8-0-g82f18fe
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
  cgroupns
 Kernel Version: 6.4.16-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 11
 Total Memory: 7.765GiB
 Name: docker-desktop
 ID: 0c850adf-94c4-45e6-97d4-fd7d753d0141
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

What happened?

After upgrading to version 0.25.0 this error occurs:

[2023-10-18T20:52:10.894Z] {"level":"error","ts":"2023-10-18 20:52:09","caller":"component/mysql_init_ms.go:33","F":"bitbucket.org/gamescale-rnd/go_tests_utils/component.StartMSSql","msg":"Error response from daemon: No such container: d11e9589adc269f7720f307f7506385110c0e9ab5580a577c3c1f2568fe23333: creating reaper failed: failed to create container"}
[2023-10-18T20:52:10.894Z] panic: runtime error: invalid memory address or nil pointer dereference [recovered]
[2023-10-18T20:52:10.894Z] 	panic: runtime error: invalid memory address or nil pointer dereference
[2023-10-18T20:52:10.894Z] [signal SIGSEGV: segmentation violation code=0x1 addr=0x68 pc=0x1000581]

this happens when i have multiple tests starting multiple containers, when i run single test(2-3 containers), no issues
when reverting back to version 0.23.0, all seems to be working well as expected

Relevant log output

[2023-10-18T20:52:04.113Z] ok  	withdrawal-go/tests/component_test_expanded_player_info	28.668s	coverage: [no statements]
[2023-10-18T20:52:04.113Z] ok  	withdrawal-go/tests/component_test_high_risk	27.613s	coverage: [no statements]
[2023-10-18T20:52:10.894Z] 2023/10/18 20:52:02 github.com/testcontainers/testcontainers-go - Connected to docker: 
[2023-10-18T20:52:10.894Z]   Server Version: 20.10.12
[2023-10-18T20:52:10.894Z]   API Version: 1.41
[2023-10-18T20:52:10.894Z]   Operating System: Ubuntu 20.04.4 LTS
[2023-10-18T20:52:10.894Z]   Total Memory: 7700 MB
[2023-10-18T20:52:10.894Z]   Resolved Docker Host: unix:///var/run/docker.sock
[2023-10-18T20:52:10.894Z]   Resolved Docker Socket Path: /var/run/docker.sock
[2023-10-18T20:52:10.894Z]   Test SessionID: 27f2a3d02835da8cca598bb5a0551abf0074cff82ea48d2670bc4c0829619808
[2023-10-18T20:52:10.894Z]   Test ProcessID: 3e61313b-c7af-465e-b3e9-d6841747cf04
[2023-10-18T20:52:10.894Z] {"level":"error","ts":"2023-10-18 20:52:09","caller":"component/mysql_init_ms.go:33","F":"bitbucket.org/gamescale-rnd/go_tests_utils/component.StartMSSql","msg":"Error response from daemon: No such container: d11e9589adc269f7720f307f7506385110c0e9ab5580a577c3c1f2568fe23333: creating reaper failed: failed to create container"}
[2023-10-18T20:52:10.894Z] panic: runtime error: invalid memory address or nil pointer dereference [recovered]
[2023-10-18T20:52:10.894Z] 	panic: runtime error: invalid memory address or nil pointer dereference
[2023-10-18T20:52:10.894Z] [signal SIGSEGV: segmentation violation code=0x1 addr=0x68 pc=0x1000581]
[2023-10-18T20:52:10.894Z] 
[2023-10-18T20:52:10.894Z] goroutine 1 [running]:
[2023-10-18T20:52:10.894Z] withdrawal-go/tests/component_test_irregular_play.TestMain.func1()
[2023-10-18T20:52:10.894Z] 	/var/lib/jenkins/workspace/nightly_go_withdrawal/tests/component_test_irregular_play/irregular_play_component_test.go:112 +0x57
[2023-10-18T20:52:10.894Z] panic({0x11e7780?, 0x1f66e30?})
[2023-10-18T20:52:10.894Z] 	/usr/local/go/src/runtime/panic.go:914 +0x21f
[2023-10-18T20:52:10.894Z] bitbucket.org/gamescale-rnd/go_tests_utils/component.StartMSSql({0x139d80d, 0xb}, {0x139d80d, 0xb}, {0x164e4c8, 0xc00006e6d8}, {0x164e4c8, 0xc00006e6e0})
[2023-10-18T20:52:10.894Z] 	/go/pkg/mod/bitbucket.org/gamescale-rnd/[email protected]/component/mysql_init_ms.go:35 +0x321
[2023-10-18T20:52:10.894Z] withdrawal-go/tests/component_test_irregular_play.TestMain(0x1394c0a?)
[2023-10-18T20:52:10.894Z] 	/var/lib/jenkins/workspace/nightly_go_withdrawal/tests/component_test_irregular_play/irregular_play_component_test.go:118 +0x22e
[2023-10-18T20:52:10.894Z] main.main()
[2023-10-18T20:52:10.894Z] 	_testmain.go:183 +0x1e6
[2023-10-18T20:52:10.894Z] FAIL	withdrawal-go/tests/component_test_irregular_play	7.585s
[2023-10-18T20:52:10.894Z] 2023/10/18 20:52:02 github.com/testcontainers/testcontainers-go - Connected to docker: 
[2023-10-18T20:52:10.894Z]   Server Version: 20.10.12
[2023-10-18T20:52:10.894Z]   API Version: 1.41
[2023-10-18T20:52:10.894Z]   Operating System: Ubuntu 20.04.4 LTS
[2023-10-18T20:52:10.894Z]   Total Memory: 7700 MB
[2023-10-18T20:52:10.894Z]   Resolved Docker Host: unix:///var/run/docker.sock
[2023-10-18T20:52:10.894Z]   Resolved Docker Socket Path: /var/run/docker.sock
[2023-10-18T20:52:10.894Z]   Test SessionID: 27f2a3d02835da8cca598bb5a0551abf0074cff82ea48d2670bc4c0829619808
[2023-10-18T20:52:10.895Z]   Test ProcessID: 6b064694-4144-441c-8cdc-eae0a06507a8
[2023-10-18T20:52:10.895Z] {"level":"error","ts":"2023-10-18 20:52:09","caller":"component/mysql_init_ms.go:33","F":"bitbucket.org/gamescale-rnd/go_tests_utils/component.StartMSSql","msg":"Error response from daemon: No such container: d11e9589adc269f7720f307f7506385110c0e9ab5580a577c3c1f2568fe23333: creating reaper failed: failed to create container"}
[2023-10-18T20:52:10.895Z] panic: runtime error: invalid memory address or nil pointer dereference [recovered]
[2023-10-18T20:52:10.895Z] 	panic: runtime error: invalid memory address or nil pointer dereference
[2023-10-18T20:52:10.895Z] [signal SIGSEGV: segmentation violation code=0x1 addr=0x68 pc=0x1050b01]


### Additional information

This log is taken from jenkins job (Ubuntu)
getting same error when running locally (MacOS)
@itziklavon itziklavon added the bug An issue with the library label Oct 19, 2023
@mdelapenya
Copy link
Member

Thanks for open this issue, I'm taking a look at the log and I find that the component/mysql_init_ms.go:33 entry is the one panicking. Could you share the code snipped in that file in order to see how the container is created? That would definitively help in identifying the root cause for this issue.

Thanks!

@itziklavon
Copy link
Author

@mdelapenya , sure:

	req := testcontainers.ContainerRequest{
		Image:        "mariadb:11.0.3",
		ExposedPorts: []string{"3306/tcp"},
		Env:          map[string]string{"MARIADB_ROOT_PASSWORD": "123123", "MARIADB_DATABASE": db},
		WaitingFor:   wait.ForLog("port: 3306"),
	}
	var err error
	mysqlCMs, err = testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
		ContainerRequest: req,
		Started:          true,
	})

	if err != nil {
		log.Error(err)
	}

seems like it is related to other issues regarding reaper timeout
when setting:

	_ = os.Setenv("TESTCONTAINERS_RYUK_RECONNECTION_TIMEOUT_DEFAULT", "2m")
	_ = os.Setenv("TESTCONTAINERS_RYUK_CONNECTION_TIMEOUT_DEFAULT", "2m")

it seems to work

@mdelapenya
Copy link
Member

@itziklavon please remember that since v0.25.0 it's possible to configure those values at the properties level. Please see #1668

@mdelapenya
Copy link
Member

@itziklavon is the issue resolved? Please let me know so we can close this issue as fixed

Thanks!

@itziklavon
Copy link
Author

@mdelapenya it is only resolved when updating the conf, without it no
but in general yes

@itziklavon
Copy link
Author

Hi
just encountered the issue again, even with timeout set to 2 minutes(tried also with 5 minutes, did not resolve, did not try more than that)
currently reverted back to version 0.23.0

tried to upgrade to 0.26.0
also did not help

something broken after version 0.23.0
version 0.23.0 works well without any issue

@DmitriyLewen
Copy link

Hello @mdelapenya
We see same error for 0.25.0 and 0.26.0 versions.

I tried using t.Setenv("TESTCONTAINERS_RYUK_RECONNECTION_TIMEOUT_DEFAULT", "10m") and t.Setenv("TESTCONTAINERS_RYUK_CONNECTION_TIMEOUT_DEFAULT", "10m"), but it didn't help.

Also i can confirm - v0.23.0 works correctly.

We get error for 2 different containers.
Requests:

	imageName := "redis:5.0"
	port := "6379/tcp"
	req := testcontainers.ContainerRequest{
		Name:         "redis",
		Image:        imageName,
		ExposedPorts: []string{port},
		SkipReaper:   true,
		AutoRemove:   true,
	}

	redis, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
		ContainerRequest: req,
		Started:          true,
	})
	req := testcontainers.ContainerRequest{
		Name:         "registry",
		Image:        registryImage,
		ExposedPorts: []string{registryPort},
		Env: map[string]string{
			"REGISTRY_HTTP_ADDR":                 "0.0.0.0:5443",
			"REGISTRY_HTTP_TLS_CERTIFICATE":      "/certs/cert.pem",
			"REGISTRY_HTTP_TLS_KEY":              "/certs/key.pem",
			"REGISTRY_AUTH":                      "token",
			"REGISTRY_AUTH_TOKEN_REALM":          fmt.Sprintf("%s/auth", authURL),
			"REGISTRY_AUTH_TOKEN_SERVICE":        "registry.docker.io",
			"REGISTRY_AUTH_TOKEN_ISSUER":         "Trivy auth server",
			"REGISTRY_AUTH_TOKEN_ROOTCERTBUNDLE": "/certs/cert.pem",
			"REGISTRY_AUTH_TOKEN_AUTOREDIRECT":   "false",
		},
		Mounts: testcontainers.Mounts(
			testcontainers.BindMount(filepath.Join(baseDir, "data", "certs"), "/certs"),
		),
		SkipReaper: true,
		AutoRemove: true,
		WaitingFor: wait.ForLog("listening on [::]:5443"),
	}

	registryC, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
		ContainerRequest: req,
		Started:          true,
	})

@DmitriyLewen
Copy link

DmitriyLewen commented Nov 2, 2023

some new information about v0.26.0:

  1. i see bug only when running multiple tests with run test containers.
    If i run only 1 test (i did this with Goland debugger) - test completes successfully.

  2. looks like SkipReaper doesn't work:

imageName := "redis:5.0"
	port := "6379/tcp"
	req := testcontainers.ContainerRequest{
		Name:         "redis",
		Image:        imageName,
		ExposedPorts: []string{port},
		AutoRemove:   true,
		SkipReaper:   true,
	}
redis, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
		ContainerRequest: req,
		Started:          true,
	})
  Server Version: 24.0.2
  API Version: 1.43
  Operating System: Docker Desktop
  Total Memory: 7851 MB
  Resolved Docker Host: unix:///var/run/docker.sock
  Resolved Docker Socket Path: /var/run/docker.sock
  Test SessionID: c64b2db77b69988577dbb2df105a962669cb5fd0632d0410d702826ec9f8e8ac
  Test ProcessID: e5c2b280-f2b1-4896-9b0b-02ab172596a6
2023/11/02 12:13:42 🐳 Creating container for image docker.io/testcontainers/ryuk:0.5.1
2023/11/02 12:13:42 ✅ Container created: faf4192b3372
2023/11/02 12:13:42 🐳 Starting container: faf4192b3372
2023/11/02 12:13:42 ✅ Container started: faf4192b3372
2023/11/02 12:13:42 🚧 Waiting for container id faf4192b3372 image: docker.io/testcontainers/ryuk:0.5.1. Waiting for: &{Port:8080/tcp timeout:<nil> PollInterval:100ms}
2023/11/02 12:13:43 🐳 Creating container for image redis:5.0
...

t.Setenv("TESTCONTAINERS_RYUK_DISABLED", "true") works as expected:

**********************************************************************************************
Ryuk has been disabled for the current execution. This can cause unexpected behavior in your environment.
More on this: https://golang.testcontainers.org/features/garbage_collector/
**********************************************************************************************
2023/11/02 12:15:22 github.com/testcontainers/testcontainers-go - Connected to docker: 
  Server Version: 24.0.2
  API Version: 1.43
  Operating System: Docker Desktop
  Total Memory: 7851 MB
  Resolved Docker Host: unix:///var/run/docker.sock
  Resolved Docker Socket Path: /var/run/docker.sock
  Test SessionID: 3228b887303b32989bb5a8ba658bed959fa3096cb3602b07c11b2e17d26aa473
  Test ProcessID: 71e73b64-128f-4658-a6cf-d63fe95855c3
2023/11/02 12:15:22 🐳 Creating container for image redis:5.0

When i used TESTCONTAINERS_RYUK_DISABLED for each our tests - all tests worked correctly.

@mdelapenya
Copy link
Member

@DmitriyLewen thanks for your report 🙏

Just to confirm with you, SkipReaper is deprecated:

SkipReaper  bool // Deprecated: The reaper is globally controlled by the .testcontainers.properties file or the TESTCONTAINERS_RYUK_DISABLED environment variable

and marked as a breaking change in #941. Please see release notes for v0.20.0: https://github.com/testcontainers/testcontainers-go/releases/tag/v0.20.0. Therefore, it's expected for using the properties or the env var to work.

something broken after version 0.23.0
version 0.23.0 works well without any issue

I'm going to look carefully to the changes in between to detect where the root cause is, but let's state the error and the expected behaviour. Let me sum up what we saw in the issue:

  1. originally, the reaper cannot be created:

[2023-10-18T20:52:10.895Z] {"level":"error","ts":"2023-10-18 20:52:09","caller":"component/mysql_init_ms.go:33","F":"bitbucket.org/gamescale-rnd/go_tests_utils/component.StartMSSql","msg":"Error response from daemon: No such container: d11e9589adc269f7720f307f7506385110c0e9ab5580a577c3c1f2568fe23333: creating reaper failed: failed to create container"}

  1. we identified that the reaper timeouts must be configured at the properties or the env var level
  2. @DmitriyLewen what is the bug you refer here? Could you please elaborate so we can work in the root cause analysis? 🙏

i see bug only when running multiple tests with run test containers.

@DmitriyLewen
Copy link

marked as a breaking change in #941.

Oh... i missed that. Thanks for information!

we identified that the reaper timeouts must be configured at the properties or the env var level

setting timeouts did not help (but when I checked it - we used SkipReaper flag)

what is the bug you refer #1782 (comment)? Could you please elaborate so we can work in the root cause analysis? 🙏

I said about error create reaper: failed to create container.
Example from our CI/CD run - https://github.com/aquasecurity/trivy/actions/runs/6716076322/job/18251767772?pr=5485#step:5:876
But I was also getting this error on my local PC (macbook m2).

@mdelapenya
Copy link
Member

@DmitriyLewen it's weird that only a few test methods failed in that GH run: if the reaper failed to be created, then it should fail for all the tests. Let me take a look at the test code for those errors 👀

@DmitriyLewen
Copy link

I thought it had something to do with the first test I ran:
AWS test didn't use reaper:
https://github.com/aquasecurity/trivy/blob/b29da24841ca4348994eec435f7370c6c3b1d151/integration/aws_cloud_test.go#L83-L89
https://github.com/aquasecurity/trivy/actions/runs/6716076322/job/18251767772?pr=5485#step:5:423

But i didn't investigation this better :(

@mdelapenya
Copy link
Member

mdelapenya commented Nov 7, 2023

I noticed all the three failing tests are disabling Ryuk: https://github.com/search?q=repo%3Aaquasecurity%2Ftrivy%20TESTCONTAINERS_RYUK_DISABLED&type=code

Just to let you know, Ryuk starts once for an entire "test session", and it's reused during that session. To understand what a test session means for us, please refer to #1513:

By test execution we mean:

  • a single "go test" invocation (including flags)
  • a single "go test ./..." invocation (including flags)
  • the execution of a single test or a set of tests using the IDE

Therefore, the containers in those tests will be managed by Ryuk, which has been created by the first test to be run. I'd like to know if possible why certain containers should not be killed by Ryuk to better understand the issue here.

@DmitriyLewen
Copy link

DmitriyLewen commented Nov 7, 2023

I don't know why these Ryuk settings were created for tests earlier (before my fix).
Most tests used SkipReaper + Terminate.

But for now we don't use Ryuk because we run Terminate after every test (I mean tests using testcontainers-go). We just don't need Ryuk in this scenario.

@mdelapenya
Copy link
Member

We just don't need Ryuk in this scenario.

Got it, thanks! In any case, Ryuk will be there even you don't want it, because it's for the entire test session. Just want to match expectations about whether Ryuk is there or not handling the lifecycle of the containers. In this case, it will. Probably it's not contributing to the root cause.

We do have this open PR about to be merged: #1904, which could be related if you are running multiple tests in multiple packages in parallel.

@mdelapenya
Copy link
Member

@DmitriyLewen given #1904 was merged, could you try with the main branch instead of the release one? I'm preparing a new release, and would like to include this big as fixed if possible.

Thanks!

@DmitriyLewen
Copy link

Hello @mdelapenya
I'll try to find time for this next week.

@mikalsande
Copy link

I have had a similar issue, though not exactly the same, figured I could just comment here with my test findings. As far as I can see #1671 is related to this issue and my issue.

I can open a separate issue if it helps.

When running on Github Actions I some times get this error with version v0.23.0, v0.25.0 and v0.26.0. There are 3 different packages in my repo that use testcontainers-go and it fails after the first package test is done. This issue only occurs when running on Github Actions, never locally on my arm64 Mac where I have been unable to reproduce the issue.

Error response from daemon: No such container: 98712a5e16b34f9494fd6cadfc24de6b5a25032294d690784d86016dd82a3132: creating reaper failed: failed to create container

Fetching the latest version from main with go get -u -t -x github.com/testcontainers/testcontainers-go@main I get the version v0.26.1-0.20231201205740-f36b5a41f090. The latest main version works any observed issues after running it multiple times, seems like #1904 fixed my issue 👍

@DmitriyLewen
Copy link

hello @mdelapenya
Sorry for waiting.

I can reproduce error when using SkipReaper (if it make sense for you, because it is depriceted):

=== RUN   TestRegistry
    registry_test.go:124: 
                Error Trace:    /Users/work/work/aqua/trivy/integration/registry_test.go:124
                Error:          Received unexpected error:
                                Error response from daemon: No such container: 967ff0f05d434ce6c3aab36cbeec762da97179312089ccc0f3579a0e1c343798: creating reaper failed: failed to create container
                Test:           TestRegistry

But looks like with t.Setenv("TESTCONTAINERS_RYUK_DISABLED", "true") tests work stable.

@acevedomiguel
Copy link

I have the same issue running multiple tests, and creating multiple instances of the containers, locally works but fails on GitHub Actions, setting TESTCONTAINERS_RYUK_DISABLED: true solves it.

@mdelapenya
Copy link
Member

@DmitriyLewen @acevedomiguel did you try with current main branch, as pointed out by @mikalsande in #1782 (comment)?

Fetching the latest version from main with go get -u -t -x github.com/testcontainers/testcontainers-go@main I get the version v0.26.1-0.20231201205740-f36b5a41f090. The latest main version works any observed issues after running it multiple times, seems like #1904 fixed my issue 👍

@DmitriyLewen
Copy link

did you try with current main branch, as pointed out by @mikalsande in #1782 (comment)?

I tried with version from main branch.

But now i rechecked this and understand that i used old localstack(perhaps this is related with error):

➜  trivy git:(b0141cfba) ✗ cat go.mod | grep github.com/testcontainers/testcontainers-go
        github.com/testcontainers/testcontainers-go v0.26.1-0.20231206105358-e9839072cc9b
        github.com/testcontainers/testcontainers-go/modules/localstack v0.21.0

Error:

=== RUN   TestRegistry
2023/12/11 08:59:31 github.com/testcontainers/testcontainers-go - Connected to docker: 
  Server Version: 24.0.2
  API Version: 1.43
  Operating System: Docker Desktop
  Total Memory: 7851 MB
  Resolved Docker Host: unix:///var/run/docker.sock
  Resolved Docker Socket Path: /var/run/docker.sock
  Test SessionID: 1ca48377acc30e1f43ac3d8898bcbfe9c292f557e41aeeb040ed0d759fd035ea
  Test ProcessID: 297ecef5-8cca-4448-9f0b-7a4a03afda97
2023/12/11 08:59:31 🐳 Creating container for image docker.io/testcontainers/ryuk:0.5.1
2023/12/11 08:59:31 ✅ Container created: e39c0294e6c3
2023/12/11 08:59:31 🐳 Starting container: e39c0294e6c3
2023/12/11 08:59:32 ✅ Container started: e39c0294e6c3
2023/12/11 08:59:32 🚧 Waiting for container id e39c0294e6c3 image: docker.io/testcontainers/ryuk:0.5.1. Waiting for: &{Port:8080/tcp timeout:<nil> PollInterval:100ms}
2023/12/11 08:59:32 🐳 Creating container for image cesanta/docker_auth:1
2023/12/11 08:59:32 ✅ Container created: 603b128e9f49
2023/12/11 08:59:32 🐳 Starting container: 603b128e9f49
2023/12/11 08:59:32 ✅ Container started: 603b128e9f49
2023/12/11 08:59:32 🐳 Creating container for image registry:2.7.0
2023/12/11 08:59:32 ✅ Container created: 1d3b320d021f
2023/12/11 08:59:32 🐳 Starting container: 1d3b320d021f
2023/12/11 08:59:32 ✅ Container started: 1d3b320d021f
2023/12/11 08:59:32 🚧 Waiting for container id 1d3b320d021f image: registry:2.7.0. Waiting for: &{timeout:<nil> Log:listening on [::]:5443 IsRegexp:false Occurrence:1 PollInterval:100ms}
2023/12/11 09:00:32 failed accessing container logs: Error response from daemon: No such container: 1d3b320d021f86ef124f88fa96bbd5c8986e18448616ed8a8efe051a38811bcc
    registry_test.go:132: 
        	Error Trace:	/Users/work/work/aqua/trivy/integration/registry_test.go:132
        	Error:      	Received unexpected error:
        	            	context deadline exceeded: failed to start container
        	Test:       	TestRegistry
2023/12/11 09:00:32 🐳 Terminating container: 603b128e9f49

@destel
Copy link

destel commented Dec 13, 2023

For me github actions broke after updating docker in the go.mod from 24.0.6+incompatible to 24.0.7+incompatible.
Locally it works just fine.

@mdelapenya
Copy link
Member

@destel are you using current main or latest release (v0.26.0)?

I'm planning to cut a release probably next week, so the Ryuk fix will be available for everybody

@destel
Copy link

destel commented Dec 15, 2023

@mdelapenya I am using v0.26.0

@mdelapenya
Copy link
Member

Ok, could you please do a quick test with main and see if it's resolved? I think #1904 should fix it

@destel
Copy link

destel commented Dec 18, 2023

@mdelapenya Unfortunately it does not work on github actions. Still works locally well.
I updated to the current master (go mod tidy also updated docker dependency to v24.0.7+incompatible) and got error: Error response from daemon: No such container: 64aa53dbe8bb109bdd449953cd3aed68394174d43d9beddb2699fa91c223890a

@mdelapenya
Copy link
Member

mdelapenya commented Dec 18, 2023

Are the GH logs available, or are they private? I wonder if we could troubleshoot them in any manner

@destel
Copy link

destel commented Dec 18, 2023

Somehow I confused myself and you. I did two builds one from the master and one from the #1094 branch.
Master works just fine. Sorry for the confusion.

@mdelapenya
Copy link
Member

@destel no worries at all... shit happens 🤷 and I'm more than happy that it resolved the error for you 👏

If everybody agree in this thread, I'm going to close this issue at the end of the day as resolved by #1904

@sebastianbuechler
Copy link
Contributor

@mdelapenya I seem to have the same issue with v0.27.0:

2024/01/29 17:56:32 🐳 Creating container for image testcontainers/ryuk:0.6.0
2024/01/29 17:56:32 ✅ Container created: 640f083847b8
2024/01/29 17:56:32 🐳 Starting container: 640f083847b8
2024/01/29 17:56:32 ✅ Container started: 640f083847b8
2024/01/29 17:56:32 🚧 Waiting for container id 640f083847b8 image: testcontainers/ryuk:0.6.0. Waiting for: &{Port:8080/tcp timeout:<nil> PollInterval:100ms}
2024/01/29 17:56:33 failed accessing container logs: Error response from daemon: No such container: 640f083847b8d3f2f582e15c21b9601839e97f2c99225e1aeebc383e3f3bad88
2024/01/29 17:56:33 Error response from daemon: No such container: 640f083847b8d3f2f582e15c21b9601839e97f2c99225e1aeebc383e3f3bad88: could not start container: creating reaper failed: failed to create container

Anything I can try?

@mdelapenya
Copy link
Member

@mdelapenya I seem to have the same issue with v0.27.0:

2024/01/29 17:56:32 🐳 Creating container for image testcontainers/ryuk:0.6.0
2024/01/29 17:56:32 ✅ Container created: 640f083847b8
2024/01/29 17:56:32 🐳 Starting container: 640f083847b8
2024/01/29 17:56:32 ✅ Container started: 640f083847b8
2024/01/29 17:56:32 🚧 Waiting for container id 640f083847b8 image: testcontainers/ryuk:0.6.0. Waiting for: &{Port:8080/tcp timeout:<nil> PollInterval:100ms}
2024/01/29 17:56:33 failed accessing container logs: Error response from daemon: No such container: 640f083847b8d3f2f582e15c21b9601839e97f2c99225e1aeebc383e3f3bad88
2024/01/29 17:56:33 Error response from daemon: No such container: 640f083847b8d3f2f582e15c21b9601839e97f2c99225e1aeebc383e3f3bad88: could not start container: creating reaper failed: failed to create container

Anything I can try?

Could you do a quick try with main? Not sure if #2084 could be related to this

@itziklavon
Copy link
Author

@mdelapenya
Hi, seems like issue persists
on more rare occasions, but it still does, version 0.23 has no issues
version 0.27 it happens to me once in every 5-6 builds

@sebastianbuechler
Copy link
Contributor

@mdelapenya I seem to have the same issue with v0.27.0:

2024/01/29 17:56:32 🐳 Creating container for image testcontainers/ryuk:0.6.0
2024/01/29 17:56:32 ✅ Container created: 640f083847b8
2024/01/29 17:56:32 🐳 Starting container: 640f083847b8
2024/01/29 17:56:32 ✅ Container started: 640f083847b8
2024/01/29 17:56:32 🚧 Waiting for container id 640f083847b8 image: testcontainers/ryuk:0.6.0. Waiting for: &{Port:8080/tcp timeout:<nil> PollInterval:100ms}
2024/01/29 17:56:33 failed accessing container logs: Error response from daemon: No such container: 640f083847b8d3f2f582e15c21b9601839e97f2c99225e1aeebc383e3f3bad88
2024/01/29 17:56:33 Error response from daemon: No such container: 640f083847b8d3f2f582e15c21b9601839e97f2c99225e1aeebc383e3f3bad88: could not start container: creating reaper failed: failed to create container

Anything I can try?

Could you do a quick try with main? Not sure if #2084 could be related to this

Sure! Upgraded to main:

$ go get github.com/testcontainers/testcontainers-go@main
go: upgraded github.com/testcontainers/testcontainers-go v0.27.0 => v0.27.1-0.20240129111620-c2cc09f409d8

Same results:

2024/01/30 09:35:56 🐳 Creating container for image testcontainers/ryuk:0.6.0
2024/01/30 09:35:56 ✅ Container created: 5b8531e7de6b
2024/01/30 09:35:56 🐳 Starting container: 5b8531e7de6b
2024/01/30 09:35:57 ✅ Container started: 5b8531e7de6b
2024/01/30 09:35:57 🚧 Waiting for container id 5b8531e7de6b image: testcontainers/ryuk:0.6.0. Waiting for: &{Port:8080/tcp timeout:<nil> PollInterval:100ms}
2024/01/30 09:35:57 failed accessing container logs: Error response from daemon: No such container: 5b8531e7de6bd762703087444ceb2fdbe2cf760ac3b07a0e51596765bf362207
2024/01/30 09:35:57 unexpected container status "removing": could not start container: creating reaper failed: failed to create container

@mdelapenya
Copy link
Member

Ummm, this is weird:

unexpected container status "removing"

I wonder if there is anything trying to remove the reaper

@sebastianbuechler
Copy link
Contributor

Ummm, this is weird:

unexpected container status "removing"

I wonder if there is anything trying to remove the reaper

It's a pretty new OS install with Docker Desktop for Windows. And I had Testcontainers Desktop running, but stopped it (had no impact on the result).

Now I deleted the existing ryuk images from the local docker images and get this output:

2024/01/30 13:29:44 github.com/testcontainers/testcontainers-go - Connected to docker: 
  Server Version: 25.0.1
  API Version: 1.44
  Operating System: Docker Desktop
  Total Memory: 15951 MB
  Resolved Docker Host: tcp://127.0.0.1:57557
  Resolved Docker Socket Path: //./pipe/docker_engine
  Test SessionID: ca6bb478ad59ce770cb34ff89af4e6136e8e47faa880208a088f2ed28c1b2f6e
  Test ProcessID: c752b91a-b9e9-4e4d-9b25-87e274ae5283
2024/01/30 13:29:44 Failed to get image auth for https://index.docker.io/v1/. Setting empty credentials for the image: testcontainers/ryuk:0.6.0. Error is:credentials not found in native keychain
2024/01/30 13:29:47 🐳 Creating container for image testcontainers/ryuk:0.6.0
2024/01/30 13:29:47 ✅ Container created: edb0291a021e
2024/01/30 13:29:47 🐳 Starting container: edb0291a021e
2024/01/30 13:29:47 ✅ Container started: edb0291a021e
2024/01/30 13:29:47 🚧 Waiting for container id edb0291a021e image: testcontainers/ryuk:0.6.0. Waiting for: &{Port:8080/tcp timeout:<nil> PollInterval:100ms}
2024/01/30 13:29:48 failed accessing container logs: Error response from daemon: No such container: edb0291a021e9cf952d8edbc8326800ee0e4100fc031725160bfcfc0d923901a
2024/01/30 13:29:48 Error response from daemon: No such container: edb0291a021e9cf952d8edbc8326800ee0e4100fc031725160bfcfc0d923901a: could not start container: creating reaper failed: failed to create container

@sebastianbuechler
Copy link
Contributor

Ummm, this is weird:

unexpected container status "removing"

I wonder if there is anything trying to remove the reaper

Is there anything I could try? The problem persists.

@mfelipe
Copy link

mfelipe commented May 20, 2024

Getting the same problem on newest version. I'm bypassing it by disabling Ryuk with the env var:

2024/05/20 11:32:44 github.com/testcontainers/testcontainers-go - Connected to docker:
Server Version: 24.0.9
API Version: 1.43
Operating System: Ubuntu 23.10
Total Memory: 1895 MB
Resolved Docker Host: unix:///Users//.colima/default/docker.sock
Resolved Docker Socket Path: /Users/
/.colima/default/docker.sock
Test SessionID: ec518445f9ec7aab73820505f60907e864948010e439d47240887f850eb99abd
Test ProcessID: 195fffd7-f4eb-4b60-bdd4-28073fd4ff9f
2024/05/20 11:32:44 🐳 Creating container for image testcontainers/ryuk:0.7.0
2024/05/20 11:32:44 ✅ Container created: c69e30ba263b
2024/05/20 11:32:44 🐳 Starting container: c69e30ba263b
2024/05/20 11:32:45 ✅ Container started: c69e30ba263b
2024/05/20 11:32:45 🚧 Waiting for container id c69e30ba263b image: testcontainers/ryuk:0.7.0. Waiting for: &{Port:8080/tcp timeout: PollInterval:100ms}
2024/05/20 11:32:45 failed accessing container logs: Error response from daemon: No such container: c69e30ba263b1852e7b4f138bc3a83485f68062a6a9fbb5d2359667134a5d81e

@vec715
Copy link

vec715 commented Jul 1, 2024

hi, any updates? This is still happens for me

@mdelapenya
Copy link
Member

@vec715 @mfelipe I think the ticket you are interested in is #2596

@fgmarand
Copy link

fgmarand commented Aug 6, 2024

I appear to have the same issue with 0.32.0 : parallel tests in Go with t.Parallel(), each creating a separate container, work normally on a local mac, but some pseudo-randomly fail on CircleCI, with the same message:

failed to start container: 
  failed waiting for reaper container 445dff25 port tcp/8080 to be ready: 
    unexpected container status "removing": 
      creating reaper failed: 
        failed to create container

(indenting added to clarify)

No problem even on CircleCI when removing the t.Parallel() calls.

@mfelipe
Copy link

mfelipe commented Aug 7, 2024

@fgmarand The error changed for me from 0.31.0 to 0.32.0, now looks more like yours.

With 0.31.0 I was able to use TESTCONTAINERS_RYUK_DISABLED=true to bypass it, but with 0.32.0 the env variables are simply ignored. I had to inject a logger to get this output, because it also stopped appearing at the STDOUT.

{"level":"info","time":"2024-08-06T23:27:59.719Z","caller":"utils/log.go:13","message":"🐳 Creating container for image testcontainers/ryuk:0.7.0"}
{"level":"info","time":"2024-08-06T23:27:59.763Z","caller":"utils/log.go:13","message":"✅ Container created: f43dd6098168"}
{"level":"info","time":"2024-08-06T23:27:59.763Z","caller":"utils/log.go:13","message":"🐳 Starting container: f43dd6098168"}
{"level":"info","time":"2024-08-06T23:27:59.919Z","caller":"utils/log.go:13","message":"✅ Container started: f43dd6098168"}
{"level":"info","time":"2024-08-06T23:27:59.922Z","caller":"utils/log.go:13","message":"⏳ Waiting for container id f43dd6098168 image: testcontainers/ryuk:0.7.0. Waiting for: &{Port:8080/tcp timeout: PollInterval:100ms}"}
{"level":"info","time":"2024-08-06T23:28:00.116Z","caller":"utils/log.go:13","message":"failed accessing container logs: Error response from daemon: No such container: f43dd60981688400aabed67a847c3cce2b89a008d0d7c7c9cf9683fe82d9f928\n"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue with the library
Projects
None yet
Development

No branches or pull requests

10 participants