當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultDockerClient.Builder方法代碼示例

本文整理匯總了Java中com.spotify.docker.client.DefaultDockerClient.Builder方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultDockerClient.Builder方法的具體用法?Java DefaultDockerClient.Builder怎麽用?Java DefaultDockerClient.Builder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.spotify.docker.client.DefaultDockerClient的用法示例。


在下文中一共展示了DefaultDockerClient.Builder方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createClient

import com.spotify.docker.client.DefaultDockerClient; //導入方法依賴的package包/類
private static DefaultDockerClient createClient(PluginSettings pluginSettings) throws Exception {
    DefaultDockerClient.Builder builder = DefaultDockerClient.builder();

    builder.uri(pluginSettings.getDockerURI());
    if (pluginSettings.getDockerURI().startsWith("https://")) {
        setupCerts(pluginSettings, builder);
    }

    if (pluginSettings.useDockerAuthInfo()) {
        RegistryAuth auth = RegistryAuth.builder()
                .password(pluginSettings.getPrivateRegistryPassword())
                .serverAddress(pluginSettings.getPrivateRegistryServer())
                .username(pluginSettings.getPrivateRegistryUsername())
                .build();
        builder.registryAuth(auth);
    }

    DefaultDockerClient docker = builder.build();
    String ping = docker.ping();
    if (!"OK".equals(ping)) {
        throw new RuntimeException("Could not ping the docker server, the server said '" + ping + "' instead of 'OK'.");
    }
    return docker;
}
 
開發者ID:gocd-contrib,項目名稱:docker-elastic-agents,代碼行數:25,代碼來源:DockerClientFactory.java

示例2: setupCerts

import com.spotify.docker.client.DefaultDockerClient; //導入方法依賴的package包/類
private static void setupCerts(PluginSettings pluginSettings, DefaultDockerClient.Builder builder) throws IOException, DockerCertificateException {
    if (isBlank(pluginSettings.getDockerCACert()) || isBlank(pluginSettings.getDockerClientCert()) || isBlank(pluginSettings.getDockerClientKey())) {
        LOG.warn("Missing docker certificates, will attempt to connect without certificates");
        return;
    }

    Path certificateDir = Files.createTempDirectory(UUID.randomUUID().toString());
    File tempDirectory = certificateDir.toFile();

    try {
        FileUtils.writeStringToFile(new File(tempDirectory, DockerCertificates.DEFAULT_CA_CERT_NAME), pluginSettings.getDockerCACert(), StandardCharsets.UTF_8);
        FileUtils.writeStringToFile(new File(tempDirectory, DockerCertificates.DEFAULT_CLIENT_CERT_NAME), pluginSettings.getDockerClientCert(), StandardCharsets.UTF_8);
        FileUtils.writeStringToFile(new File(tempDirectory, DockerCertificates.DEFAULT_CLIENT_KEY_NAME), pluginSettings.getDockerClientKey(), StandardCharsets.UTF_8);
        builder.dockerCertificates(new DockerCertificates(certificateDir));
    } finally {
        FileUtils.deleteDirectory(tempDirectory);
    }
}
 
開發者ID:gocd-contrib,項目名稱:docker-elastic-agents,代碼行數:19,代碼來源:DockerClientFactory.java

示例3: createClient

import com.spotify.docker.client.DefaultDockerClient; //導入方法依賴的package包/類
private static DefaultDockerClient createClient(PluginSettings pluginSettings) throws Exception {
    DefaultDockerClient.Builder builder = DefaultDockerClient.builder();

    builder.uri(pluginSettings.getDockerURI());
    if (pluginSettings.getDockerURI().startsWith("https://")) {
        setupCerts(pluginSettings, builder);
    }

    if (pluginSettings.useDockerAuthInfo()) {
        final RegistryAuth registryAuth = pluginSettings.registryAuth();
        LOG.info(format("Using private docker registry server `{0}`.", registryAuth.serverAddress()));
        builder.registryAuth(registryAuth);
    }

    DefaultDockerClient docker = builder.build();
    String ping = docker.ping();
    if (!"OK".equals(ping)) {
        throw new RuntimeException("Could not ping the docker server, the server said '" + ping + "' instead of 'OK'.");
    }
    return docker;
}
 
開發者ID:gocd-contrib,項目名稱:docker-swarm-elastic-agents,代碼行數:22,代碼來源:DockerClientFactory.java

示例4: createClient

import com.spotify.docker.client.DefaultDockerClient; //導入方法依賴的package包/類
private DefaultDockerClient createClient() {
    DefaultDockerClient dockerClient;
    Optional<DockerCertificates> certs = Optional.absent();
    if (mccySettings.getDockerCertPath() != null) {
        try {
            certs = DockerCertificates.builder()
                    .dockerCertPath(Paths.get(mccySettings.getDockerCertPath())).build();
        } catch (DockerCertificateException e) {
            throw new IllegalArgumentException("Unable to initialize Docker certificates with given configuration");
        }
    }

    final DefaultDockerClient.Builder clientBuilder = DefaultDockerClient.builder();

    if (certs.isPresent()) {
        clientBuilder
                .dockerCertificates(certs.get());
    }

    dockerClient = clientBuilder
            .uri(mccySettings.getDockerHostUri())
            .build();
    return dockerClient;
}
 
開發者ID:moorkop,項目名稱:mccy-engine,代碼行數:25,代碼來源:DockerClientProxyImpl.java

示例5: DockerClientSpotify

import com.spotify.docker.client.DefaultDockerClient; //導入方法依賴的package包/類
public DockerClientSpotify() {
    messageConsole = new DockerClientMessageConsole(Constants.CONSOLE_NAME);
    dockerConfig = new DockerConfig();

    final String endpoint = dockerConfig.getUri();
    final String dockerCertPath = dockerConfig.getDockerCertPath();

    final DefaultDockerClient.Builder builder = new DefaultDockerClient.Builder();
    builder.uri(endpoint);
    builder.readTimeoutMillis(DefaultDockerClient.NO_TIMEOUT);

    if (dockerCertPath != null && !dockerCertPath.isEmpty()) {
        try {
            builder.dockerCertificates(new DockerCertificates(Paths
                    .get(dockerCertPath)));
        } catch (DockerCertificateException e) {
            messageConsole.getDockerConsoleOut().println(
                    "[ERROR] " + e.toString());
        }
    }

    dockerClient = builder.build();
}
 
開發者ID:domeide,項目名稱:doclipser,代碼行數:24,代碼來源:DockerClientSpotify.java

示例6: build

import com.spotify.docker.client.DefaultDockerClient; //導入方法依賴的package包/類
@Override
public DefaultDockerClient.Builder build(HttpRestApiHost host) {
	return DefaultDockerClient
		.builder()
		.uri(host.getUri())
	;
}
 
開發者ID:petercipov,項目名稱:mobi,代碼行數:8,代碼來源:SpotifyClientBuilder.java

示例7: SpotifyRxDocker

import com.spotify.docker.client.DefaultDockerClient; //導入方法依賴的package包/類
public SpotifyRxDocker(DefaultDockerClient.Builder builder, Scheduler scheduler) {
	this.clientBuilder = builder;
	this.scheduler = scheduler;
	this.clients = Collections.synchronizedMap(new HashMap<>());
}
 
開發者ID:petercipov,項目名稱:mobi,代碼行數:6,代碼來源:SpotifyRxDocker.java


注:本文中的com.spotify.docker.client.DefaultDockerClient.Builder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。