use of com.spotify.docker.client.DockerCertificateException in project kie-wb-common by kiegroup.
the class DockerAccessInterfaceImpl method buildClient.
private DockerClient buildClient(final ProviderId providerId) throws DockerException, InterruptedException {
DefaultDockerClient dockerClient;
if (providerId.getId().equals("local")) {
try {
if (System.getProperty("os.name").toLowerCase().contains("mac")) {
dockerClient = DefaultDockerClient.builder().uri(DefaultDockerClient.DEFAULT_UNIX_ENDPOINT).build();
// This test the docker client connection to see if the client was built properly
Info info = dockerClient.info();
LOG.info("Connected to Docker Client Info: " + info);
return dockerClient;
}
try {
dockerClient = DefaultDockerClient.fromEnv().build();
Info info = dockerClient.info();
LOG.info("Connected to Docker Client Info: " + info);
return dockerClient;
} catch (DockerCertificateException ex) {
throw new RuntimeException(ex);
}
} catch (DockerException | InterruptedException ex) {
try {
dockerClient = DefaultDockerClient.fromEnv().build();
Info info = dockerClient.info();
LOG.info("Connected to Docker Client Info: " + info);
return dockerClient;
} catch (DockerCertificateException e) {
throw new RuntimeException(e);
}
}
}
throw new RuntimeException("Couldn't create Docker Client, for providerId = " + providerId.getId());
}
use of com.spotify.docker.client.DockerCertificateException in project docker-api-spring-boot by jliu666.
the class DockerClientAutoConfiguration method dockerClient.
@Bean
@ConditionalOnMissingBean(DockerClient.class)
public DockerClient dockerClient() {
DefaultDockerClient.Builder builder = null;
try {
builder = DefaultDockerClient.fromEnv();
} catch (DockerCertificateException e) {
e.printStackTrace();
}
if (builder == null) {
builder = DefaultDockerClient.builder();
}
if (!StringUtils.isEmpty(dockerClientProperties.getApiVersion())) {
builder.apiVersion(dockerClientProperties.getApiVersion());
}
if (!StringUtils.isEmpty(dockerClientProperties.getDockerHost())) {
builder.uri(dockerClientProperties.getDockerHost());
}
if (dockerClientProperties.getDockerTlsVerify() != null) {
String scheme = builder.uri().getScheme();
if (dockerClientProperties.getDockerTlsVerify() && "http".equals(scheme.toLowerCase())) {
builder.uri(builder.uri().toString().replaceFirst("http", "https"));
}
if (!dockerClientProperties.getDockerTlsVerify() && "https".equals(scheme.toLowerCase())) {
builder.uri(builder.uri().toString().replaceFirst("https", "http"));
}
}
DockerCertificates certificates = getCertificates();
if (null != certificates) {
builder.dockerCertificates();
} else {
builder.dockerCertificates(certificates);
}
builder.authConfig(getAuthConfig());
return builder.build();
}
Aggregations