Search in sources :

Example 1 with Builder

use of com.github.dockerjava.httpclient5.ApacheDockerHttpClient.Builder in project quorum-acceptance-tests by ConsenSys.

the class DockerInfrastructureService method afterPropertiesSet.

@Override
public void afterPropertiesSet() throws Exception {
    DefaultDockerClientConfig.Builder configBuilder = DefaultDockerClientConfig.createDefaultConfigBuilder();
    if (StringUtils.isNotBlank(networkProperty().getDockerInfrastructure().getHost())) {
        configBuilder.withDockerHost(networkProperty().getDockerInfrastructure().getHost());
    }
    DefaultDockerClientConfig config = configBuilder.build();
    infraProperty = networkProperty().getDockerInfrastructure();
    DockerHttpClient httpClient = new ApacheDockerHttpClient.Builder().dockerHost(config.getDockerHost()).sslConfig(config.getSSLConfig()).build();
    dockerClient = DockerClientImpl.getInstance(config, httpClient);
    quorumDockerImageCatalog = ImmutableMap.<String, QuorumImageConfig>builder().put("develop", new QuorumImageConfig(Optional.ofNullable(infraProperty.getTargetQuorumImage()).orElse("quorumengineering/quorum:develop"), GethArgBuilder.newBuilder().allowInsecureUnlock(true))).put("latest", new QuorumImageConfig("quorumengineering/quorum:latest", GethArgBuilder.newBuilder().allowInsecureUnlock(true))).put("v2.5.0", new QuorumImageConfig("quorumengineering/quorum:2.5.0", GethArgBuilder.newBuilder())).put("21.1.0", new QuorumImageConfig("quorumengineering/quorum:21.1.0", GethArgBuilder.newBuilder().allowInsecureUnlock(true))).put("21.4.0", new QuorumImageConfig("quorumengineering/quorum:21.4.0", GethArgBuilder.newBuilder().allowInsecureUnlock(true))).put("21.10.0", new QuorumImageConfig("quorumengineering/quorum:21.10.0", GethArgBuilder.newBuilder().allowInsecureUnlock(true))).put("2.7.0", new QuorumImageConfig("quorumengineering/quorum:2.7.0", GethArgBuilder.newBuilder().allowInsecureUnlock(true))).build();
    tesseraDockerImageCatalog = ImmutableMap.of("develop", Optional.ofNullable(infraProperty.getTargetTesseraImage()).orElse("quorumengineering/tessera:develop"), "latest", "quorumengineering/tessera:latest", "0.10.5", "quorumengineering/tessera:0.10.5", "21.1.0", "quorumengineering/tessera:21.1.0", "21.10.0", "quorumengineering/tessera:21.10.0");
}
Also used : ApacheDockerHttpClient(com.github.dockerjava.httpclient5.ApacheDockerHttpClient) DefaultDockerClientConfig(com.github.dockerjava.core.DefaultDockerClientConfig) ApacheDockerHttpClient(com.github.dockerjava.httpclient5.ApacheDockerHttpClient) DockerHttpClient(com.github.dockerjava.transport.DockerHttpClient)

Example 2 with Builder

use of com.github.dockerjava.httpclient5.ApacheDockerHttpClient.Builder in project Jpom by dromara.

the class TestSwarm method client.

private DockerClient client(String host) {
    DefaultDockerClientConfig.Builder builder = DefaultDockerClientConfig.createDefaultConfigBuilder().withDockerHost("tcp://" + host + ":2375");
    if (StrUtil.equals(host, nodeLt)) {
        builder.withDockerTlsVerify(true).withDockerCertPath("/Users/user/fsdownload/docker-ca");
    }
    DockerClientConfig config = builder.build();
    DockerHttpClient httpClient = new ApacheDockerHttpClient.Builder().dockerHost(config.getDockerHost()).sslConfig(config.getSSLConfig()).maxConnections(100).build();
    DockerClient dockerClient = DockerClientImpl.getInstance(config, httpClient);
    dockerClient.pingCmd().exec();
    return dockerClient;
}
Also used : DockerClient(com.github.dockerjava.api.DockerClient) DefaultDockerClientConfig(com.github.dockerjava.core.DefaultDockerClientConfig) DockerClientConfig(com.github.dockerjava.core.DockerClientConfig) DefaultDockerClientConfig(com.github.dockerjava.core.DefaultDockerClientConfig) ApacheDockerHttpClient(com.github.dockerjava.httpclient5.ApacheDockerHttpClient) DockerHttpClient(com.github.dockerjava.transport.DockerHttpClient)

Example 3 with Builder

use of com.github.dockerjava.httpclient5.ApacheDockerHttpClient.Builder in project synopsys-detect by blackducksoftware.

the class DetectDockerRunner method connectToDocker.

public DockerClient connectToDocker() {
    DefaultDockerClientConfig.Builder builder = DefaultDockerClientConfig.createDefaultConfigBuilder();
    // But for Windows, unless told not to: use the Windows default docker host value
    if (OperatingSystemType.determineFromSystem() == OperatingSystemType.WINDOWS) {
        builder.withDockerHost("npipe:////./pipe/docker_engine");
    }
    DockerClientConfig config = builder.build();
    DockerHttpClient httpClient = new ApacheDockerHttpClient.Builder().dockerHost(config.getDockerHost()).sslConfig(config.getSSLConfig()).maxConnections(100).build();
    return DockerClientImpl.getInstance(config, httpClient);
}
Also used : DefaultDockerClientConfig(com.github.dockerjava.core.DefaultDockerClientConfig) DockerClientConfig(com.github.dockerjava.core.DockerClientConfig) DefaultDockerClientConfig(com.github.dockerjava.core.DefaultDockerClientConfig) ApacheDockerHttpClient(com.github.dockerjava.httpclient5.ApacheDockerHttpClient) DockerHttpClient(com.github.dockerjava.transport.DockerHttpClient)

Example 4 with Builder

use of com.github.dockerjava.httpclient5.ApacheDockerHttpClient.Builder in project webdrivermanager by bonigarcia.

the class DockerService method getDockerClient.

private DockerClient getDockerClient(String dockerHost) {
    DefaultDockerClientConfig.Builder dockerClientConfigBuilder = DefaultDockerClientConfig.createDefaultConfigBuilder();
    if (!isNullOrEmpty(dockerHost)) {
        dockerClientConfigBuilder.withDockerHost(dockerHost);
    }
    DockerClientConfig dockerClientConfig = dockerClientConfigBuilder.build();
    dockerHostUri = dockerClientConfig.getDockerHost();
    ApacheDockerHttpClient dockerHttpClient = new Builder().dockerHost(dockerHostUri).build();
    return DockerClientBuilder.getInstance(dockerClientConfig).withDockerHttpClient(dockerHttpClient).build();
}
Also used : Builder(com.github.dockerjava.httpclient5.ApacheDockerHttpClient.Builder) DockerBuilder(io.github.bonigarcia.wdm.docker.DockerContainer.DockerBuilder) DockerClientBuilder(com.github.dockerjava.core.DockerClientBuilder) ApacheDockerHttpClient(com.github.dockerjava.httpclient5.ApacheDockerHttpClient) DefaultDockerClientConfig(com.github.dockerjava.core.DefaultDockerClientConfig) DockerClientConfig(com.github.dockerjava.core.DockerClientConfig) DefaultDockerClientConfig(com.github.dockerjava.core.DefaultDockerClientConfig)

Example 5 with Builder

use of com.github.dockerjava.httpclient5.ApacheDockerHttpClient.Builder in project kestra by kestra-io.

the class DockerScriptRunner method getDockerClient.

private DockerClient getDockerClient(AbstractBash abstractBash, RunContext runContext, Path workingDirectory) throws IllegalVariableEvaluationException, IOException {
    DefaultDockerClientConfig.Builder dockerClientConfigBuilder = DefaultDockerClientConfig.createDefaultConfigBuilder();
    if (abstractBash.getDockerOptions() != null) {
        if (abstractBash.getDockerOptions().getDockerHost() != null) {
            dockerClientConfigBuilder.withDockerHost(runContext.render(abstractBash.getDockerOptions().getDockerHost()));
        }
        if (abstractBash.getDockerOptions().getDockerConfig() != null) {
            Path docker = Files.createTempDirectory(workingDirectory, "docker");
            Path file = Files.createFile(docker.resolve("config.json"));
            Files.write(file, runContext.render(abstractBash.getDockerOptions().getDockerConfig()).getBytes());
            dockerClientConfigBuilder.withDockerConfig(docker.toFile().getAbsolutePath());
        }
    }
    DockerClientConfig dockerClientConfig = dockerClientConfigBuilder.build();
    ApacheDockerHttpClient dockerHttpClient = new Builder().dockerHost(dockerClientConfig.getDockerHost()).build();
    return DockerClientBuilder.getInstance(dockerClientConfig).withDockerHttpClient(dockerHttpClient).build();
}
Also used : Path(java.nio.file.Path) DockerClientBuilder(com.github.dockerjava.core.DockerClientBuilder) Builder(com.github.dockerjava.httpclient5.ApacheDockerHttpClient.Builder) ApacheDockerHttpClient(com.github.dockerjava.httpclient5.ApacheDockerHttpClient) DefaultDockerClientConfig(com.github.dockerjava.core.DefaultDockerClientConfig) DockerClientConfig(com.github.dockerjava.core.DockerClientConfig) DefaultDockerClientConfig(com.github.dockerjava.core.DefaultDockerClientConfig)

Aggregations

DefaultDockerClientConfig (com.github.dockerjava.core.DefaultDockerClientConfig)7 ApacheDockerHttpClient (com.github.dockerjava.httpclient5.ApacheDockerHttpClient)7 DockerClientConfig (com.github.dockerjava.core.DockerClientConfig)6 DockerHttpClient (com.github.dockerjava.transport.DockerHttpClient)4 DockerClient (com.github.dockerjava.api.DockerClient)2 DockerClientBuilder (com.github.dockerjava.core.DockerClientBuilder)2 Builder (com.github.dockerjava.httpclient5.ApacheDockerHttpClient.Builder)2 DockerBuilder (io.github.bonigarcia.wdm.docker.DockerContainer.DockerBuilder)1 Path (java.nio.file.Path)1