com.github.dockerjava.core.DockerClientImpl Java Examples

The following examples show how to use com.github.dockerjava.core.DockerClientImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DockerClientProviderStrategy.java    From testcontainers-java with MIT License 6 votes vote down vote up
protected DockerClient getClientForConfig(DockerClientConfig config) {
    config = new AuthDelegatingDockerClientConfig(config);
    final DockerHttpClient dockerHttpClient;

    String transportType = TestcontainersConfiguration.getInstance().getTransportType();
    switch (transportType) {
        case "okhttp":
            dockerHttpClient = new OkDockerHttpClient.Builder()
                .dockerHost(config.getDockerHost())
                .sslConfig(config.getSSLConfig())
                .build();
            break;
        case "httpclient5":
            dockerHttpClient = new ZerodepDockerHttpClient.Builder()
                .dockerHost(config.getDockerHost())
                .sslConfig(config.getSSLConfig())
                .build();
            break;
        default:
            throw new IllegalArgumentException("Unknown transport type '" + transportType + "'");
    }

    return DockerClientImpl.getInstance(config, dockerHttpClient);
}
 
Example #2
Source File: CustomCommandIT.java    From docker-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testCustomCommand() throws Exception {
    DockerHttpClient httpClient = ((DockerClientImpl) dockerRule.getClient()).getHttpClient();

    Assume.assumeNotNull(httpClient);

    Request request = Request.builder()
        .method(Request.Method.GET)
        .path("/_ping")
        .build();

    try (Response response = httpClient.execute(request)) {
        assertThat(response.getStatusCode(), equalTo(200));
        assertThat(IOUtils.toString(response.getBody(), StandardCharsets.UTF_8), equalTo("OK"));
    }
}
 
Example #3
Source File: DockerImpl.java    From vespa with Apache License 2.0 5 votes vote down vote up
private static DockerClient createDockerClient() {
    JerseyDockerCmdExecFactory dockerFactory = new JerseyDockerCmdExecFactory()
            .withMaxPerRouteConnections(10)
            .withMaxTotalConnections(100)
            .withConnectTimeout((int) Duration.ofSeconds(100).toMillis())
            .withReadTimeout((int) Duration.ofMinutes(30).toMillis());

    DockerClientConfig dockerClientConfig = new DefaultDockerClientConfig.Builder()
            .withDockerHost("unix:///var/run/docker.sock")
            .build();

    return DockerClientImpl.getInstance(dockerClientConfig)
            .withDockerCmdExecFactory(dockerFactory);
}
 
Example #4
Source File: CmdIT.java    From docker-java with Apache License 2.0 5 votes vote down vote up
@Override
public DockerClientImpl createDockerClient(DockerClientConfig config) {
    return (DockerClientImpl) DockerClientBuilder.getInstance(config)
        .withDockerCmdExecFactory(
            new NettyDockerCmdExecFactory()
                .withConnectTimeout(30 * 1000)
        )
        .build();
}
 
Example #5
Source File: CmdIT.java    From docker-java with Apache License 2.0 5 votes vote down vote up
@Override
public DockerClientImpl createDockerClient(DockerClientConfig config) {
    return (DockerClientImpl) DockerClientBuilder.getInstance(config)
        .withDockerHttpClient(
            new TrackingDockerHttpClient(
                new JerseyDockerHttpClient.Builder()
                    .dockerHost(config.getDockerHost())
                    .sslConfig(config.getSSLConfig())
                    .connectTimeout(30 * 1000)
                    .build()
            )
        )
        .build();
}
 
Example #6
Source File: CmdIT.java    From docker-java with Apache License 2.0 5 votes vote down vote up
@Override
public DockerClientImpl createDockerClient(DockerClientConfig config) {
    return (DockerClientImpl) DockerClientBuilder.getInstance(config)
        .withDockerHttpClient(
            new TrackingDockerHttpClient(
                new OkDockerHttpClient.Builder()
                    .dockerHost(config.getDockerHost())
                    .sslConfig(config.getSSLConfig())
                    .connectTimeout(30 * 100)
                    .build()
            )
        )
        .build();
}
 
Example #7
Source File: CmdIT.java    From docker-java with Apache License 2.0 5 votes vote down vote up
@Override
public DockerClientImpl createDockerClient(DockerClientConfig config) {
    return (DockerClientImpl) DockerClientBuilder.getInstance(config)
        .withDockerHttpClient(
            new TrackingDockerHttpClient(
                new ApacheDockerHttpClient.Builder()
                    .dockerHost(config.getDockerHost())
                    .sslConfig(config.getSSLConfig())
                    .build()
            )
        )
        .build();
}
 
Example #8
Source File: DockerConfig.java    From gaia with Mozilla Public License 2.0 4 votes vote down vote up
/**
 * builds the docker client
 * @param config the configuration (host/registries...)
 * @return
 */
@Bean
DockerClient client(DockerClientConfig config){
    return DockerClientImpl.getInstance(config)
        .withDockerCmdExecFactory(new OkHttpDockerCmdExecFactory());
}
 
Example #9
Source File: AbstractDockerMojo.java    From docker-maven-plugin with MIT License 4 votes vote down vote up
public DockerClient getDockerClient(String url) {
    return dockerClient != null ? dockerClient : DockerClientImpl.getInstance(url);
}
 
Example #10
Source File: CmdIT.java    From docker-java with Apache License 2.0 votes vote down vote up
public abstract DockerClientImpl createDockerClient(DockerClientConfig config);