Skip to content

Commit

Permalink
Merge pull request #287 from dddpaul/custom_tiny_image
Browse files Browse the repository at this point in the history
Add ability to override DockerClientFactory.TINY_IMAGE in testcontainers.properties
  • Loading branch information
rnorth committed Feb 5, 2017
2 parents 2b2d34f + c4a30d8 commit d623ddc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j;
import org.testcontainers.dockerclient.*;
import org.testcontainers.utility.TestcontainersConfiguration;

import java.util.List;
import java.util.Optional;
Expand All @@ -28,7 +29,7 @@
@Slf4j
public class DockerClientFactory {

private static final String TINY_IMAGE = "alpine:3.2";
private static final String TINY_IMAGE = TestcontainersConfiguration.getInstance().getTinyImage();
private static DockerClientFactory instance;

// Cached client configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class TestcontainersConfiguration {

private String ambassadorContainerImage = "richnorth/ambassador:latest";
private String vncRecordedContainerImage = "richnorth/vnc-recorder:latest";
private String tinyImage = "alpine:3.2";

private static TestcontainersConfiguration loadConfiguration() {
final TestcontainersConfiguration config = new TestcontainersConfiguration();
Expand All @@ -42,6 +43,7 @@ private static TestcontainersConfiguration loadConfiguration() {

config.ambassadorContainerImage = properties.getProperty("ambassador.container.image", config.ambassadorContainerImage);
config.vncRecordedContainerImage = properties.getProperty("vncrecorder.container.image", config.vncRecordedContainerImage);
config.tinyImage = properties.getProperty("tinyimage.container.image", config.tinyImage);

log.debug("Testcontainers configuration overrides loaded from {}: {}", configOverrides, config);

Expand Down
3 changes: 3 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,12 @@ Testcontainers uses additional docker images under some modes of execution:

> *N.B.:* both these images use the 'latest' tag, which could potentially affect repeatability of tests and compatibility with Testcontainers _if the image is ever changed_. This is a [known issue](https://github.com/testcontainers/testcontainers-java/issues/276) which will be addressed in the future. The current 'latest' version of these images will never be changed until they are replaced by a new image altogether.
Last but not least, `alpine:3.2` image is used for Docker host IP address detection in some special cases.

If it is necessary to override these image names (e.g. when using a private registry), you should create a file named `testcontainers.properties` and place it on the classpath with the following content:

```properties
ambassador.container.image=replacement image name here
vncrecorder.container.image=replacement image name here
tinyimage.container.image=replacement image name here
```

0 comments on commit d623ddc

Please sign in to comment.