protected DockerClient getNewDockerClient() throws Exception { if (isNullOrEmpty(DOCKER_HOST.dockerCertPath())) { return new DefaultDockerClient(DOCKER_HOST.uri()); } else { final Path dockerCertPath = java.nio.file.Paths.get(DOCKER_HOST.dockerCertPath()); return new DefaultDockerClient(DOCKER_HOST.uri(), new DockerCertificates(dockerCertPath)); } }
private DockerClient createDockerClient(final AgentConfig config) throws IOException { final DefaultDockerClient.Builder builder = DefaultDockerClient.builder() .uri(config.getDockerHost().uri()); if (config.getConnectionPoolSize() != -1) { builder.connectionPoolSize(config.getConnectionPoolSize()); } if (!isNullOrEmpty(config.getDockerHost().dockerCertPath())) { final Path dockerCertPath = java.nio.file.Paths.get(config.getDockerHost().dockerCertPath()); final DockerCertificates dockerCertificates; try { dockerCertificates = new DockerCertificates(dockerCertPath); } catch (DockerCertificateException e) { throw new RuntimeException(e); } builder.dockerCertificates(dockerCertificates); } if (config.getGoogleCredentials() != null) { builder.registryAuthSupplier( ContainerRegistryAuthSupplier .forCredentials(config.getGoogleCredentials()) .build() ); } return new PollingDockerClient(builder); }
@Override protected void runOneIteration() throws InterruptedException { final String hostname = exec("uname -n").trim(); final String uname = exec("uname -a").trim(); final HostInfo hostInfo = HostInfo.newBuilder() .setArchitecture(operatingSystemMxBean.getArch()) .setCpus(Runtime.getRuntime().availableProcessors()) .setHostname(hostname) .setLoadAvg(operatingSystemMxBean.getSystemLoadAverage()) .setOsName(operatingSystemMxBean.getName()) .setOsVersion(operatingSystemMxBean.getVersion()) .setMemoryFreeBytes(operatingSystemMxBean.getFreePhysicalMemorySize()) .setMemoryTotalBytes(operatingSystemMxBean.getTotalPhysicalMemorySize()) .setSwapFreeBytes(operatingSystemMxBean.getFreeSwapSpaceSize()) .setSwapTotalBytes(operatingSystemMxBean.getTotalSwapSpaceSize()) .setUname(uname) .setDockerVersion(dockerVersion()) .setDockerHost(dockerHost()) .setDockerCertPath(dockerHost.dockerCertPath()) .build(); nodeUpdater.update(hostInfo.toJsonBytes()); }
.setDefault(DockerHost.fromEnv().dockerCertPath()) .help("directory containing client.pem and client.key for connecting to Docker over HTTPS");