fix: normalize bare host:port Docker host values to prevent URI parse failure (#665)

Co-authored-by: Dixit R Jain <dixitrjain@Dixits-MacBook-Pro.local>
This commit is contained in:
Dixit R JainandDixit R Jain authored and GitHub committed 2026-04-30 17:22:34 -05:00
1 parent f30bd79d67
commit 2dd748ee07
2 files changed
+147 -1

No files matched your search

@@ -27,10 +27,33 @@ public class DockerClientProducer {
this.config = config;
}
/**
* Normalizes a Docker host value by prepending {@code tcp://} when no recognized
* URI scheme ({@code tcp://}, {@code unix://}, {@code npipe://}) is present.
*
* @param dockerHost the raw Docker host configuration value
* @return the normalized Docker host value, or the original value if it already has a scheme
*/
static String normalizeDockerHost(String dockerHost) {
if (dockerHost == null) {
return null;
}
if (dockerHost.isEmpty()) {
return dockerHost;
}
String lower = dockerHost.toLowerCase();
if (lower.startsWith("tcp://") || lower.startsWith("unix://") || lower.startsWith("npipe://")) {
return dockerHost;
}
String normalized = "tcp://" + dockerHost;
LOG.infov("Docker host value ''{0}'' has no URI scheme; normalizing to ''{1}''", dockerHost, normalized);
return normalized;
}
@Produces
@ApplicationScoped
public DockerClient dockerClient() {
String dockerHost = config.docker().dockerHost();
String dockerHost = normalizeDockerHost(config.docker().dockerHost());
LOG.infov("Creating DockerClient for host: {0}", dockerHost);
DefaultDockerClientConfig.Builder builder = DefaultDockerClientConfig.createDefaultConfigBuilder()