Hi I'm just starting with Testcontainers and ran into the following issue.
I have a working docker compose file, which starts a mongodb container and a jboss keycloak container and link the two together.
When attempting to start the containers using the DockerComposeContainer class the containers are actually started (I validated it with running docker ps). But the unit test hangs with the following exception in the logs:
12:17:58.131 [pool-5-thread-1] ERROR 馃惓 [richnorth/ambassador:latest] - Could not start container
org.testcontainers.containers.ContainerLaunchException: Aborting attempt to link to container prhk5h_keycloak_1 as it is not running
at org.testcontainers.containers.GenericContainer.applyConfiguration(GenericContainer.java:368)
at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:190)
at org.testcontainers.containers.GenericContainer.lambda$start$0(GenericContainer.java:171)
.....
Any ideas why the ambassador might not be able to detect the containers are correctly started?
The @ClassRule code I'm using is:
public static DockerComposeContainer environment = new DockerComposeContainer(dockerComposeFile)
.withExposedService("mongo", MONGO_PORT)
.withExposedService("keycloak", KEYCLOAK_PORT)
.withPull(false);
The docker-compose.yml file is as following:
version: '2'
services:
mongo:
image: mongo
container_name: mongo
ports:
- "27017:27017"
environment:
- MONGODB_DBNAME=keycloak
keycloak:
image: keycloak-photoz
container_name: keycloak
environment:
- KEYCLOAK_USER=admin
- KEYCLOAK_PASSWORD=password
- MONGO_PORT_27017_TCP_ADDR=mongo:27017
ports:
- "8080:8080"
links:
- mongo:mongo
depends_on:
- mongo
Hi @richard77,
I see you're using container_name. Could you please try to remove it and run it again?
Hi @bsideup!
Thanks for the quick answer!
That did the trick for me.. I assume I was unintentionally overriding a generated name by using the container_name field.
@richard77 happy to hear that the issue is solved!
Most helpful comment
Hi @richard77,
I see you're using
container_name. Could you please try to remove it and run it again?