Skip to content

DockerComposeContainer fails to connect ambassador to spawned containers #265

@richard77

Description

@richard77

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions