Skip to content

Is there a way to set the memory capacity for a GenericContainer? #298

@macks22

Description

@macks22

I have the following GenericContainer:

/**
 * A docker container that can be used with an @ClassRule to start the container before
 * and tear it down after a test class. This container exposes port 9200 as 9201 and port 9300 as 9301.
 * It also copies over the elasticsearch.yml file from the test resources.
 */
public class ElasticsearchTestContainer extends GenericContainer {

    private static final ImageFromDockerfile IMAGE_FROM_DOCKERFILE =
            new ImageFromDockerfile("test-es-image", false)
                    .withDockerfileFromBuilder(builder -> builder
                            .from("elasticsearch:2.2")
                            .run("/usr/share/elasticsearch/bin/plugin install analysis-icu")
                            .run("/usr/share/elasticsearch/bin/plugin install delete-by-query")
                            .copy("elasticsearch.yml", "/usr/share/elasticsearch/config/elasticsearch.yml")
                            .build()
                    ).withFileFromClasspath("elasticsearch.yml", "docker/elasticsearch.yml");

    public ElasticsearchTestContainer() {
        super(IMAGE_FROM_DOCKERFILE);
        this.setPortBindings(Arrays.asList("9201:9200", "9301:9300"));
        this.setNetworkMode("devhost.hostname.com");
        this.setWaitStrategy(Wait.forHttp("/"));
    }
}

Normally, I would specify the memory using the -m flag to docker. How can I do this with this container?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions