Skip to content
Merged
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 @@ -98,11 +98,13 @@ public class DefaultDockerClientConfig implements Serializable, DockerClientConf
}

private URI checkDockerHostScheme(URI dockerHost) {
if ("tcp".equals(dockerHost.getScheme()) || "unix".equals(dockerHost.getScheme())) {
return dockerHost;
} else {
throw new DockerClientException("Unsupported protocol scheme found: '" + dockerHost
+ "'. Only 'tcp://' or 'unix://' supported.");
switch (dockerHost.getScheme()) {
case "tcp":
case "unix":
case "npipe":
return dockerHost;
default:
throw new DockerClientException("Unsupported protocol scheme found: '" + dockerHost);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,20 @@ public void init(DockerClientConfig dockerClientConfig) {
protocol = "http";
}

if (!originalUri.getScheme().equals("unix")) {

try {
originalUri = new URI(originalUri.toString().replaceFirst("tcp", protocol));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
switch (originalUri.getScheme()) {
case "unix":
break;
case "tcp":
try {
originalUri = new URI(originalUri.toString().replaceFirst("tcp", protocol));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}

configureProxy(clientConfig, originalUri, protocol);
configureProxy(clientConfig, originalUri, protocol);
break;
default:
throw new IllegalArgumentException("Unsupported protocol scheme: " + originalUri);
}

connManager = new PoolingHttpClientConnectionManager(getSchemeRegistry(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,18 @@ public void init(DockerClientConfig dockerClientConfig) {
String scheme = dockerClientConfig.getDockerHost().getScheme();
String host = "";

if ("unix".equals(scheme)) {
nettyInitializer = new UnixDomainSocketInitializer();
host = "DUMMY";
} else if ("tcp".equals(scheme)) {
nettyInitializer = new InetSocketInitializer();
host = dockerClientConfig.getDockerHost().getHost() + ":"
+ Integer.toString(dockerClientConfig.getDockerHost().getPort());
switch (scheme) {
case "unix":
nettyInitializer = new UnixDomainSocketInitializer();
host = "DUMMY";
break;
case "tcp":
nettyInitializer = new InetSocketInitializer();
host = dockerClientConfig.getDockerHost().getHost() + ":"
+ Integer.toString(dockerClientConfig.getDockerHost().getPort());
break;
default:
throw new IllegalArgumentException("Unsupported protocol scheme: " + dockerClientConfig.getDockerHost());
}

eventLoopGroup = nettyInitializer.init(bootstrap, dockerClientConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ public void testUnixHostScheme() throws Exception {
null);
}

@Test()
public void testNpipeHostScheme() throws Exception {
new DefaultDockerClientConfig(URI.create("npipe://foo"), "dockerConfig", "apiVersion", "registryUrl", "registryUsername", "registryPassword", "registryEmail",
null);
}

@Test
public void withDockerTlsVerify() throws Exception {
DefaultDockerClientConfig.Builder builder = new DefaultDockerClientConfig.Builder();
Expand Down