Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public EnvironmentAndSystemPropertyClientProviderStrategy() {
case "autoIgnoringUserProperties":
applicable = configBuilder.isDockerHostSetExplicitly();
break;
case "dockerContext":
// none of the Testcontainers configuration are relevant when using docker contexts since we rely
// on the docker-java default to have all the necessary configuration already set.
applicable = true;
break;
default:
throw new InvalidConfigurationException("Invalid value for dockerconfig.source: " + dockerConfigSource);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,20 @@ void notApplicableWhenIgnoringUserPropertiesAndNotConfigured() {

assertThat(strategy.isApplicable()).isFalse();
}

@Test
void applicableWhenUsingDockerContext() {
Mockito
.doReturn("dockerContext")
.when(TestcontainersConfiguration.getInstance())
.getEnvVarOrProperty(eq("dockerconfig.source"), anyString());

Properties oldProperties = System.getProperties();
try {
EnvironmentAndSystemPropertyClientProviderStrategy strategy = new EnvironmentAndSystemPropertyClientProviderStrategy();
assertThat(strategy.isApplicable()).isTrue();
} finally {
System.setProperties(oldProperties);
}
}
}
8 changes: 8 additions & 0 deletions docs/features/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,11 @@ In addition, you can deactivate this behaviour by specifying:
```properties
dockerconfig.source=autoIgnoringUserProperties # 'auto' by default
```

## Docker Context support

For users who wants to use docker context for host configuration can set the following property:
```properties
dockerconfig.source=dockerContext # 'auto' by default
```
Warning, this option will not do any extra checks, it defaults to whatever is configured through docker and/or docker context
Loading