testcontainers-java: [Bug]: Container fails to start after upgrade from 1.18.1 to 1.18.2

Module

PostgreSQL

Testcontainers version

1.18.2

Using the latest Testcontainers version?

Yes

Host OS

MacOS Ventura 13.4

Host Arch

ARM (Apple M2)

Docker version

Client:
 Cloud integration: v1.0.33
 Version:           24.0.2
 API version:       1.43
 Go version:        go1.20.4
 Git commit:        cb74dfc
 Built:             Thu May 25 21:51:16 2023
 OS/Arch:           darwin/arm64
 Context:           desktop-linux

Server: Docker Desktop 4.20.0 (109717)
 Engine:
  Version:          24.0.2
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.4
  Git commit:       659604f
  Built:            Thu May 25 21:50:59 2023
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
 runc:
  Version:          1.1.7
  GitCommit:        v1.1.7-0-g860f061
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

What happened?

After upgrading org.testcontainers:postgresql dependency from 1.18.1 to 1.18.2 tests fail to run.

Failure happens in .start method:

PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:15.2");
postgres.start();

Relevant log output

2023-05-30 17:09:31  INFO  ImageNameSubstitutor - Image name substitution will be performed by: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor')
2023-05-30 17:09:31  INFO  DockerClientProviderStrategy - Loaded org.testcontainers.dockerclient.UnixSocketClientProviderStrategy from ~/.testcontainers.properties, will try it first
2023-05-30 17:09:32  INFO  DockerClientProviderStrategy - Found Docker environment with Testcontainers Host with tc.host=unix:///Users/andrei/.docker/run/docker.sock
2023-05-30 17:09:32  INFO  DockerClientFactory - Docker host IP address is localhost
2023-05-30 17:09:32  INFO  DockerClientFactory - Connected to docker: 
  Server Version: 24.0.2
  API Version: 1.43
  Operating System: Docker Desktop
  Total Memory: 7851 MB
2023-05-30 17:09:32  INFO  1 - Pulling docker image: testcontainers/ryuk:0.5.1. Please be patient; this may take some time but only needs to be done once.
2023-05-30 17:09:32  INFO  RegistryAuthLocator - Credential helper/store (docker-credential-desktop) does not have credentials for https://index.docker.io/v1/
2023-05-30 17:09:32  INFO  1 - Starting to pull image
2023-05-30 17:09:32  INFO  1 - Pulling image layers:  0 pending,  0 downloaded,  0 extracted, (0 bytes/0 bytes)
2023-05-30 17:09:33  INFO  1 - Pulling image layers:  2 pending,  1 downloaded,  0 extracted, (304 KB/? MB)
2023-05-30 17:09:33  INFO  1 - Pulling image layers:  2 pending,  1 downloaded,  1 extracted, (2 MB/? MB)
2023-05-30 17:09:33  INFO  1 - Pulling image layers:  2 pending,  1 downloaded,  2 extracted, (2 MB/? MB)
2023-05-30 17:09:33  INFO  1 - Pulling image layers:  1 pending,  2 downloaded,  2 extracted, (2 MB/? MB)
2023-05-30 17:09:33  INFO  1 - Pulling image layers:  1 pending,  2 downloaded,  3 extracted, (5 MB/? MB)
2023-05-30 17:09:33  INFO  1 - Creating container for image: testcontainers/ryuk:0.5.1
2023-05-30 17:09:33  INFO  1 - Container testcontainers/ryuk:0.5.1 is starting: 70f4088e24cda89ca1ab5c0a7218b977b519920bdcbee8b292e6b3fb1af81795
2023-05-30 17:09:33  ERROR 1 - Could not start container
com.github.dockerjava.api.exception.NotFoundException: Status 404: {"message":"No such container: 70f4088e24cda89ca1ab5c0a7218b977b519920bdcbee8b292e6b3fb1af81795"}

	at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:241) ~[testcontainers-1.18.2.jar:1.18.2]
	at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.get(DefaultInvocationBuilder.java:202) ~[testcontainers-1.18.2.jar:1.18.2]
	at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.get(DefaultInvocationBuilder.java:74) ~[testcontainers-1.18.2.jar:1.18.2]
	at org.testcontainers.shaded.com.github.dockerjava.core.exec.InspectContainerCmdExec.execute(InspectContainerCmdExec.java:31) ~[testcontainers-1.18.2.jar:1.18.2]
	at org.testcontainers.shaded.com.github.dockerjava.core.exec.InspectContainerCmdExec.execute(InspectContainerCmdExec.java:13) ~[testcontainers-1.18.2.jar:1.18.2]
	at org.testcontainers.shaded.com.github.dockerjava.core.exec.AbstrSyncDockerCmdExec.exec(AbstrSyncDockerCmdExec.java:21) ~[testcontainers-1.18.2.jar:1.18.2]
	at org.testcontainers.shaded.com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:35) ~[testcontainers-1.18.2.jar:1.18.2]
	at org.testcontainers.shaded.com.github.dockerjava.core.command.InspectContainerCmdImpl.exec(InspectContainerCmdImpl.java:52) ~[testcontainers-1.18.2.jar:1.18.2]
	at org.testcontainers.containers.GenericContainer.lambda$tryStart$1(GenericContainer.java:456) ~[testcontainers-1.18.2.jar:?]
	at org.testcontainers.shaded.org.awaitility.core.AbstractHamcrestCondition.lambda$new$0(AbstractHamcrestCondition.java:48) ~[testcontainers-1.18.2.jar:1.18.2]
	at org.testcontainers.shaded.org.awaitility.core.ConditionAwaiter$ConditionPoller.call(ConditionAwaiter.java:248) ~[testcontainers-1.18.2.jar:1.18.2]
	at org.testcontainers.shaded.org.awaitility.core.ConditionAwaiter$ConditionPoller.call(ConditionAwaiter.java:235) ~[testcontainers-1.18.2.jar:1.18.2]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
	at org.testcontainers.shaded.org.awaitility.core.SameThreadExecutorService.execute(SameThreadExecutorService.java:79) ~[testcontainers-1.18.2.jar:1.18.2]
	at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) ~[?:?]
	at org.testcontainers.shaded.org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:101) ~[testcontainers-1.18.2.jar:1.18.2]
	at org.testcontainers.shaded.org.awaitility.core.AbstractHamcrestCondition.await(AbstractHamcrestCondition.java:86) ~[testcontainers-1.18.2.jar:1.18.2]
	at org.testcontainers.shaded.org.awaitility.core.ConditionFactory.until(ConditionFactory.java:985) ~[testcontainers-1.18.2.jar:1.18.2]
	at org.testcontainers.shaded.org.awaitility.core.ConditionFactory.until(ConditionFactory.java:691) ~[testcontainers-1.18.2.jar:1.18.2]
	at org.testcontainers.shaded.org.awaitility.core.ConditionFactory.until(ConditionFactory.java:708) ~[testcontainers-1.18.2.jar:1.18.2]
	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:455) ~[testcontainers-1.18.2.jar:?]
	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:344) ~[testcontainers-1.18.2.jar:?]
	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81) ~[duct-tape-1.0.8.jar:?]
	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:334) ~[testcontainers-1.18.2.jar:?]
	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322) ~[testcontainers-1.18.2.jar:?]
	at org.testcontainers.utility.RyukResourceReaper.maybeStart(RyukResourceReaper.java:78) ~[testcontainers-1.18.2.jar:1.18.2]
	at org.testcontainers.utility.RyukResourceReaper.init(RyukResourceReaper.java:42) ~[testcontainers-1.18.2.jar:1.18.2]
	at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:229) ~[testcontainers-1.18.2.jar:1.18.2]
	at org.testcontainers.DockerClientFactory$1.getDockerClient(DockerClientFactory.java:104) ~[testcontainers-1.18.2.jar:1.18.2]
	at com.github.dockerjava.api.DockerClientDelegate.authConfig(DockerClientDelegate.java:109) ~[docker-java-api-3.3.0.jar:?]
	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:321) ~[testcontainers-1.18.2.jar:?]
	at com.breakingequity.marketdata.database.TestDatabase.init(TestDatabase.java:26) ~[test-classes/:?]
.....


2023-05-30 17:09:33  ERROR 1 - There are no stdout/stderr logs available for the failed container

org.testcontainers.containers.ContainerLaunchException: Container startup failed for image testcontainers/ryuk:0.5.1

	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:349)
	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
	at org.testcontainers.utility.RyukResourceReaper.maybeStart(RyukResourceReaper.java:78)
	at org.testcontainers.utility.RyukResourceReaper.init(RyukResourceReaper.java:42)
	at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:229)
	at org.testcontainers.DockerClientFactory$1.getDockerClient(DockerClientFactory.java:104)
	at com.github.dockerjava.api.DockerClientDelegate.authConfig(DockerClientDelegate.java:109)
	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:321)
	at com.breakingequity.marketdata.database.TestDatabase.init(TestDatabase.java:26)
....
Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:88)
	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:334)
	... 80 more
Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:553)
	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:344)
	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
	... 81 more
Caused by: com.github.dockerjava.api.exception.NotFoundException: Status 404: {"message":"No such container: 70f4088e24cda89ca1ab5c0a7218b977b519920bdcbee8b292e6b3fb1af81795"}

	at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:241)
	at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.get(DefaultInvocationBuilder.java:202)
	at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.get(DefaultInvocationBuilder.java:74)
	at org.testcontainers.shaded.com.github.dockerjava.core.exec.InspectContainerCmdExec.execute(InspectContainerCmdExec.java:31)
	at org.testcontainers.shaded.com.github.dockerjava.core.exec.InspectContainerCmdExec.execute(InspectContainerCmdExec.java:13)
	at org.testcontainers.shaded.com.github.dockerjava.core.exec.AbstrSyncDockerCmdExec.exec(AbstrSyncDockerCmdExec.java:21)
	at org.testcontainers.shaded.com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:35)
	at org.testcontainers.shaded.com.github.dockerjava.core.command.InspectContainerCmdImpl.exec(InspectContainerCmdImpl.java:52)
	at org.testcontainers.containers.GenericContainer.lambda$tryStart$1(GenericContainer.java:456)
	at org.testcontainers.shaded.org.awaitility.core.AbstractHamcrestCondition.lambda$new$0(AbstractHamcrestCondition.java:48)
	at org.testcontainers.shaded.org.awaitility.core.ConditionAwaiter$ConditionPoller.call(ConditionAwaiter.java:248)
	at org.testcontainers.shaded.org.awaitility.core.ConditionAwaiter$ConditionPoller.call(ConditionAwaiter.java:235)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.testcontainers.shaded.org.awaitility.core.SameThreadExecutorService.execute(SameThreadExecutorService.java:79)
	at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
	at org.testcontainers.shaded.org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:101)
	at org.testcontainers.shaded.org.awaitility.core.AbstractHamcrestCondition.await(AbstractHamcrestCondition.java:86)
	at org.testcontainers.shaded.org.awaitility.core.ConditionFactory.until(ConditionFactory.java:985)
	at org.testcontainers.shaded.org.awaitility.core.ConditionFactory.until(ConditionFactory.java:691)
	at org.testcontainers.shaded.org.awaitility.core.ConditionFactory.until(ConditionFactory.java:708)
	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:455)
	... 83 more

Additional Information

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 6
  • Comments: 34 (14 by maintainers)

Commits related to this issue

Most upvoted comments

Testcontainers for Java 1.18.3 is out https://repo1.maven.org/maven2/org/testcontainers/testcontainers/1.18.3/testcontainers-1.18.3.pom

Thank you so much for testing it so quickly and raising the issue again!

I had a similar issue and adding the following line to the .testcontainers.properties file solved it for me

~/.testcontainers.properties

ryuk.container.privileged=true

I am still getting the same error, upgrading to 1.18.3 did not fix this issue.

I am using Mac M1. podman version 4.5.1

~/.testcontainers.properties docker.client.strategy=org.testcontainers.dockerclient.UnixSocketClientProviderStrategy

Caused by: org.testcontainers.containers.ContainerLaunchException: Container startup failed for image testcontainers/ryuk:0.5.1 at app//org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:349) at app//org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322) at app//org.testcontainers.utility.RyukResourceReaper.maybeStart(RyukResourceReaper.java:78) at app//org.testcontainers.utility.RyukResourceReaper.init(RyukResourceReaper.java:42) at app//org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:229) at app//org.testcontainers.DockerClientFactory$1.getDockerClient(DockerClientFactory.java:104) at app//com.github.dockerjava.api.DockerClientDelegate.authConfig(DockerClientDelegate.java:109) at app//org.testcontainers.containers.GenericContainer.start(GenericContainer.java:321)

I had the same issue on my M1 Mac and resolved it from these instructions here: https://vividcode.io/colima-apple-m-1-and-testcontainers/

I set the following environment variables:

DOCKER_HOST=“unix://$HOME/.colima/default/docker.sock” TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock TESTCONTAINERS_RYUK_DISABLED=true

I am getting the same error on mac m1/colima docker

14:57:24.760 [Test worker] ERROR tc.testcontainers/ryuk:0.5.1 - There are no stdout/stderr logs available for the failed container

Container startup failed for image testcontainers/ryuk:0.5.1
org.testcontainers.containers.ContainerLaunchException: Container startup failed for image testcontainers/ryuk:0.5.1
	at app//org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:349)
	at app//org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
	at app//org.testcontainers.utility.RyukResourceReaper.maybeStart(RyukResourceReaper.java:78)
	at app//org.testcontainers.utility.RyukResourceReaper.init(RyukResourceReaper.java:42)
	at app//org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:229)
	at app//org.testcontainers.DockerClientFactory$1.getDockerClient(DockerClientFactory.java:104)
	at app//com.github.dockerjava.api.DockerClientDelegate.authConfig(DockerClientDelegate.java:109)
	at app//org.testcontainers.containers.GenericContainer.start(GenericContainer.java:321)

Now, I’m able to reproduce and see the reason. Thank you so much for reporting this issue!

Do you have /var/run/docker.sock? which Docker Desktop for Mac version are you using?

What if you delete the ~/.testcontainers.properties and run the test again?

Interesting. When I stop at line 31-32 of TestcontainersHostPropertyClientProviderStrategy in debug after:

        Optional<String> tcHost = Optional.ofNullable(
            TestcontainersConfiguration.getInstance().getUserProperty("tc.host", null)
        );

tcHost variable is Optional.empty, so it’s coming from somewhere else, will keep you posted if I notice something else.