com.github.dockerjava.core.DockerClientConfig Java Examples
The following examples show how to use
com.github.dockerjava.core.DockerClientConfig.
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 |
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: NettyDockerCmdExecFactory.java From docker-java with Apache License 2.0 | 6 votes |
@Override public EventLoopGroup init(Bootstrap bootstrap, final DockerClientConfig dockerClientConfig) { EventLoopGroup nioEventLoopGroup = new NioEventLoopGroup(0, new DefaultThreadFactory(threadPrefix)); InetAddress addr = InetAddress.getLoopbackAddress(); final SocketAddress proxyAddress = new InetSocketAddress(addr, 8008); Security.addProvider(new BouncyCastleProvider()); ChannelFactory<NioSocketChannel> factory = () -> configure(new NioSocketChannel()); bootstrap.group(nioEventLoopGroup).channelFactory(factory) .handler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(final SocketChannel channel) throws Exception { // channel.pipeline().addLast(new // HttpProxyHandler(proxyAddress)); channel.pipeline().addLast(new HttpClientCodec()); channel.pipeline().addLast(new HttpContentDecompressor()); } }); return nioEventLoopGroup; }
Example #3
Source File: ITTestBase.java From hudi with Apache License 2.0 | 5 votes |
@BeforeEach public void init() { String dockerHost = (OVERRIDDEN_DOCKER_HOST != null) ? OVERRIDDEN_DOCKER_HOST : DEFAULT_DOCKER_HOST; // Assuming insecure docker engine DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder().withDockerHost(dockerHost).build(); // using jaxrs/jersey implementation here (netty impl is also available) DockerCmdExecFactory dockerCmdExecFactory = new JerseyDockerCmdExecFactory().withConnectTimeout(1000) .withMaxTotalConnections(100).withMaxPerRouteConnections(10); dockerClient = DockerClientBuilder.getInstance(config).withDockerCmdExecFactory(dockerCmdExecFactory).build(); await().atMost(60, SECONDS).until(this::servicesUp); }
Example #4
Source File: NpipeSocketClientProviderStrategy.java From testcontainers-java with MIT License | 5 votes |
@NotNull private DockerClientConfig tryConfiguration() { config = new DelegatingDockerClientConfig( DefaultDockerClientConfig.createDefaultConfigBuilder() .withDockerHost(SOCKET_LOCATION) .withDockerTlsVerify(false) .build() ); client = getClientForConfig(config); final int timeout = Integer.parseInt(System.getProperty(PING_TIMEOUT_PROPERTY_NAME, PING_TIMEOUT_DEFAULT)); ping(client, timeout); return config; }
Example #5
Source File: CmdIT.java From docker-java with Apache License 2.0 | 5 votes |
@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: DockerConfig.java From gaia with Mozilla Public License 2.0 | 5 votes |
/** * builds the DockerClientConfig based on Gaia's settings * @param settings Gaia's settings * @return a docker client configuration */ @Bean DockerClientConfig dockerClientConfig(Settings settings) { return DefaultDockerClientConfig.createDefaultConfigBuilder() .withDockerHost(settings.getDockerDaemonUrl()) .build(); }
Example #7
Source File: OkHttpDockerCmdExecFactory.java From docker-java with Apache License 2.0 | 5 votes |
@Override public void init(DockerClientConfig dockerClientConfig) { clientBuilder = clientBuilder .dockerHost(dockerClientConfig.getDockerHost()) .sslConfig(dockerClientConfig.getSSLConfig()); dockerCmdExecFactory = new DefaultDockerCmdExecFactory( clientBuilder.build(), dockerClientConfig.getObjectMapper() ); dockerCmdExecFactory.init(dockerClientConfig); }
Example #8
Source File: DockerClientFactory.java From minimesos with Apache License 2.0 | 5 votes |
public static DockerClient build() { if (dockerClient == null) { DefaultDockerClientConfig.Builder builder = new DefaultDockerClientConfig.Builder(); builder = builder.withApiVersion("1.12"); String dockerHostEnv = System.getenv("DOCKER_HOST"); if (StringUtils.isBlank(dockerHostEnv)) { builder.withDockerHost("unix:///var/run/docker.sock"); } DockerClientConfig config = builder.build(); dockerClient = DockerClientBuilder.getInstance(config).build(); } return dockerClient; }
Example #9
Source File: DockerClientFactoryBean.java From Dolphin with Apache License 2.0 | 5 votes |
public DockerClient getObject() throws Exception { DockerClientConfig config = DockerClientConfig.createDefaultConfigBuilder() .withVersion(version) .withUri(uri) .withUsername(username) .withPassword(password) .withEmail(email) .withServerAddress(serverAddress) .withDockerCertPath(dockerCertPath) .build(); return DockerClientBuilder.getInstance(config).build(); }
Example #10
Source File: CmdIT.java From docker-java with Apache License 2.0 | 5 votes |
@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 #11
Source File: JerseyDockerCmdExecFactory.java From docker-java with Apache License 2.0 | 5 votes |
@Override public void init(DockerClientConfig dockerClientConfig) { clientBuilder = clientBuilder .dockerHost(dockerClientConfig.getDockerHost()) .sslConfig(dockerClientConfig.getSSLConfig()); dockerCmdExecFactory = new DefaultDockerCmdExecFactory( clientBuilder.build(), dockerClientConfig.getObjectMapper() ); dockerCmdExecFactory.init(dockerClientConfig); }
Example #12
Source File: NettyDockerCmdExecFactory.java From docker-java with Apache License 2.0 | 5 votes |
@Override public DuplexChannel connect(Bootstrap bootstrap) throws InterruptedException { DockerClientConfig dockerClientConfig = getDockerClientConfig(); String host = dockerClientConfig.getDockerHost().getHost(); int port = dockerClientConfig.getDockerHost().getPort(); if (port == -1) { throw new RuntimeException("no port configured for " + host); } final DuplexChannel channel = (DuplexChannel) bootstrap.connect(host, port).sync().channel(); final SslHandler ssl = initSsl(dockerClientConfig); if (ssl != null) { channel.pipeline().addFirst(ssl); // https://tools.ietf.org/html/rfc5246#section-7.2.1 // TLS has its own special message about connection termination. Because TLS is a // session-level protocol, it can be covered by any transport-level protocol like // TCP, UTP and so on. But we know exactly that data being transferred over TCP and // that other side will never send any byte into this TCP connection, so this // channel should be closed. // RFC says that we must notify opposite side about closing. This could be done only // in sun.security.ssl.SSLEngineImpl and unfortunately it does not send this // message. On the other hand RFC does not enforce the opposite side to wait for // such message. ssl.sslCloseFuture().addListener(future -> channel.eventLoop().execute(channel::close)); } return channel; }
Example #13
Source File: NettyDockerCmdExecFactory.java From docker-java with Apache License 2.0 | 5 votes |
@Override public DuplexChannel connect(Bootstrap bootstrap) throws InterruptedException { DockerClientConfig dockerClientConfig = getDockerClientConfig(); String path = dockerClientConfig.getDockerHost().getPath(); return (DuplexChannel) bootstrap.connect(new DomainSocketAddress(path)).sync().channel(); }
Example #14
Source File: DockerUtils.java From azure-libraries-for-java with MIT License | 5 votes |
/** * Creates a DockerClientConfig object to be used when creating the Java Docker client using a secured connection. * @param host - Docker host address (IP) to connect to * @param registryServerUrl - address of the private container registry * @param username - user name to connect with to the private container registry * @param password - password to connect with to the private container registry * @param caPemContent - content of the ca.pem certificate file * @param keyPemContent - content of the key.pem certificate file * @param certPemContent - content of the cert.pem certificate file * @return an instance of DockerClient configuration */ public static DockerClientConfig createDockerClientConfig(String host, String registryServerUrl, String username, String password, String caPemContent, String keyPemContent, String certPemContent) { return DefaultDockerClientConfig.createDefaultConfigBuilder() .withDockerHost(host) .withDockerTlsVerify(true) .withCustomSslConfig(new DockerSSLConfig(caPemContent, keyPemContent, certPemContent)) .withRegistryUrl(registryServerUrl) .withRegistryUsername(username) .withRegistryPassword(password) .build(); }
Example #15
Source File: DockerConnector.java From cloudml with GNU Lesser General Public License v3.0 | 5 votes |
public DockerConnector(String endPoint, String version){ DockerClientConfig config = DockerClientConfig.createDefaultConfigBuilder() .withVersion(version) .withUri(endPoint) .build(); dockerClient = DockerClientBuilder.getInstance(config).build(); }
Example #16
Source File: DockerClientFactory.java From Core with MIT License | 5 votes |
private static DockerClient get( String host, Boolean tlsVerify, String certPath, String registryUsername, String registryPass, String registryMail, String registryUrl ) { DefaultDockerClientConfig.Builder configBuilder = DefaultDockerClientConfig.createDefaultConfigBuilder() .withDockerHost(host); configBuilder.withDockerTlsVerify(tlsVerify); if (!certPath.equals("")) { configBuilder.withDockerCertPath(certPath); } if(!registryUrl.equals("")) { configBuilder.withRegistryUrl(registryUrl); if (!registryUsername.equals("")) { configBuilder.withRegistryUsername(registryUsername); } if (!registryMail.equals("")) { configBuilder.withRegistryEmail(registryMail); } if (!registryPass.equals("")) { configBuilder.withRegistryPassword(registryPass); } } DockerClientConfig config = configBuilder.build(); return DockerClientBuilder.getInstance(config).build(); }
Example #17
Source File: DockerContainerManagementService.java From wecube-platform with Apache License 2.0 | 5 votes |
public DockerClient newDockerClient(String host) { String url = String.format("tcp://%s:%d", host,dockerRemoteProperties.getPort()); if(dockerRemoteProperties.getEnableTls() == true){ DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder() .withDockerHost(url) .withDockerTlsVerify(true) .withDockerCertPath(dockerRemoteProperties.getCertPath()) .build(); return DockerClientBuilder.getInstance(config).build(); }else{ return DockerClientBuilder.getInstance(url).build(); } }
Example #18
Source File: CreateImageCmdExec.java From docker-java with Apache License 2.0 | 4 votes |
public CreateImageCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) { super(baseResource, dockerClientConfig); }
Example #19
Source File: PingCmdExec.java From docker-java with Apache License 2.0 | 4 votes |
public PingCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) { super(baseResource, dockerClientConfig); }
Example #20
Source File: InitializeSwarmCmdExec.java From docker-java with Apache License 2.0 | 4 votes |
public InitializeSwarmCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) { super(baseResource, dockerClientConfig); }
Example #21
Source File: WaitContainerCmdExec.java From docker-java with Apache License 2.0 | 4 votes |
public WaitContainerCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) { super(baseResource, dockerClientConfig); }
Example #22
Source File: ResizeContainerCmdExec.java From docker-java with Apache License 2.0 | 4 votes |
public ResizeContainerCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) { super(baseResource, dockerClientConfig); }
Example #23
Source File: StopContainerCmdExec.java From docker-java with Apache License 2.0 | 4 votes |
public StopContainerCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) { super(baseResource, dockerClientConfig); }
Example #24
Source File: RestartContainerCmdExec.java From docker-java with Apache License 2.0 | 4 votes |
public RestartContainerCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) { super(baseResource, dockerClientConfig); }
Example #25
Source File: StartContainerCmdExec.java From docker-java with Apache License 2.0 | 4 votes |
public StartContainerCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) { super(baseResource, dockerClientConfig); }
Example #26
Source File: ExecStartCmdExec.java From docker-java with Apache License 2.0 | 4 votes |
public ExecStartCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) { super(baseResource, dockerClientConfig); }
Example #27
Source File: RemoveServiceCmdExec.java From docker-java with Apache License 2.0 | 4 votes |
public RemoveServiceCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) { super(baseResource, dockerClientConfig); }
Example #28
Source File: ContainerDiffCmdExec.java From docker-java with Apache License 2.0 | 4 votes |
public ContainerDiffCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) { super(baseResource, dockerClientConfig); }
Example #29
Source File: DisconnectFromNetworkCmdExec.java From docker-java with Apache License 2.0 | 4 votes |
public DisconnectFromNetworkCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) { super(baseResource, dockerClientConfig); }
Example #30
Source File: SaveImagesCmdExec.java From docker-java with Apache License 2.0 | 4 votes |
public SaveImagesCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) { super(baseResource, dockerClientConfig); }