Skip to content

Commit

Permalink
Add ability to specify docker image in KafkaContainer. (testcontainer…
Browse files Browse the repository at this point in the history
…s#580)

* Add ability to specify docker image in KafkaContainer.

* Added 'kafka.container.image' property to TestcontainersConfiguration in order to have an opportunity to replace default image with testcontainers.properties.

* Return version argument to KafkaContainer constructor.
  • Loading branch information
irasikhin authored and bsideup committed Feb 9, 2018
1 parent a9da708 commit 4e15af8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public String getRyukImage() {
return (String) properties.getOrDefault("ryuk.container.image", "bsideup/moby-ryuk:0.2.2");
}

public String getKafkaImage() {
return (String) properties.getOrDefault("kafka.container.image", "confluentinc/cp-kafka");
}

public boolean isDisableChecks() {
return Boolean.parseBoolean((String) properties.getOrDefault("checks.disable", "false"));
}
Expand Down
3 changes: 3 additions & 0 deletions docs/usage/properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@ It takes a couple of seconds, but if you want to speed up your tests, you can di
> **compose.container.image = docker/compose:1.8.0**
> Used by Docker Compose integration
> **kafka.container.image = confluentinc/cp-kafka**
> Used by KafkaContainer
Testcontainers uses public Docker images to perform different actions like startup checks, VNC recording and others.
Some companies disallow the usage of Docker Hub, but you can override `*.image` properties with your own images from your private registry to workaround that.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.testcontainers.containers;

import org.testcontainers.utility.Base58;
import org.testcontainers.utility.TestcontainersConfiguration;

import java.util.stream.Stream;

Expand All @@ -23,7 +24,7 @@ public KafkaContainer() {
}

public KafkaContainer(String confluentPlatformVersion) {
super("confluentinc/cp-kafka:" + confluentPlatformVersion);
super(TestcontainersConfiguration.getInstance().getKafkaImage() + ":" + confluentPlatformVersion);

withNetwork(Network.newNetwork());
String networkAlias = "kafka-" + Base58.randomString(6);
Expand Down

0 comments on commit 4e15af8

Please sign in to comment.