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


Java DockerClient.pull方法代碼示例

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


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

示例1: predownloadImagesIfRequired

import com.spotify.docker.client.DockerClient; //導入方法依賴的package包/類
private static void predownloadImagesIfRequired() throws DockerException, InterruptedException {

        DockerClient client = getClient();
        LOG.warning("Commencing download of images.");
        Collection<MappingInfo> images = getInstance().getMapping().values();

        ProgressHandler handler = new LoggingBuildHandler();
        for (MappingInfo image : images) {
            List<Image> foundImages = client.listImages(DockerClient.ListImagesParam.byName(image.getTarget()));
            if (! foundImages.isEmpty()) {
                LOG.warning(String.format("Skipping download for Image [%s] because it's already available.",
                    image.getTarget()));
                continue;
            }
            client.pull(image.getTarget(), handler);
        }
    }
 
開發者ID:RationaleEmotions,項目名稱:just-ask,代碼行數:18,代碼來源:DockerHelper.java

示例2: init

import com.spotify.docker.client.DockerClient; //導入方法依賴的package包/類
@Override
public void init() throws Exception {
    Assume.assumeTrue(DockerTestUtils.isDockerAvailable());

    this.creds = new DockerRegistryCredentials(
        "127.0.0.1:5000",
        "",
        "",
        "testing"
    );

    DockerClient client = DefaultDockerClient.fromEnv().build();
    logger.info("Downloading registry image");
    client.pull("registry:2");

    final Map<String, List<PortBinding>> ports = singletonMap(
        "5000/tcp", Collections.singletonList(PortBinding.of("0.0.0.0", 5000)));
    final HostConfig hostConfig = HostConfig.builder().portBindings(ports)
        .build();

    logger.info("Creating Local Registry Container");
    ContainerConfig config = ContainerConfig.builder()
        .hostConfig(hostConfig)
        .image("registry:2").build();
    String id = client.createContainer(config).id();
    logger.info("Registry container id: {}", id);

    logger.info("Starting registry container");
    client.startContainer(id);
    this.registryid = id;
}
 
開發者ID:StuPro-TOSCAna,項目名稱:TOSCAna,代碼行數:32,代碼來源:PushingImageBuilderIT.java

示例3: validate

import com.spotify.docker.client.DockerClient; //導入方法依賴的package包/類
@Override
public void validate(String tag) throws Exception {
    DockerClient client = DefaultDockerClient.fromEnv().authConfig(creds.toAuthConfig()).build();
    client.removeImage(tag);
    //Pull the image from the registry
    client.pull(tag);
}
 
開發者ID:StuPro-TOSCAna,項目名稱:TOSCAna,代碼行數:8,代碼來源:PushingImageBuilderIT.java

示例4: pullImage

import com.spotify.docker.client.DockerClient; //導入方法依賴的package包/類
private void pullImage(DockerClient docker, String imageRepoName) throws DockerException, InterruptedException {
    final RegistryAuth registryAuth = RegistryAuth.builder()
            .email(System.getenv("DOCKER_EMAIL"))
            .username(System.getenv("DOCKER_USERNAME"))
            .password(System.getenv("DOCKER_PASSWORD"))
            .build();

    final int statusCode = docker.auth(registryAuth);
    logger.info("Docker registry auth status: " + statusCode);
    docker.pull(imageRepoName, registryAuth);
}
 
開發者ID:sjsucohort6,項目名稱:amigo-chatbot,代碼行數:12,代碼來源:DockerTask.java

示例5: create

import com.spotify.docker.client.DockerClient; //導入方法依賴的package包/類
public static DockerContainer create(CreateAgentRequest request, PluginSettings settings, DockerClient docker) throws InterruptedException, DockerException, IOException {
    String containerName = UUID.randomUUID().toString();

    HashMap<String, String> labels = labelsFrom(request);
    String imageName = image(request.properties());
    List<String> env = environmentFrom(request, settings, containerName);

    try {
        docker.inspectImage(imageName);
    } catch (ImageNotFoundException ex) {
        LOG.info("Image " + imageName + " not found, attempting to download.");
        docker.pull(imageName);
    }

    ContainerConfig.Builder containerConfigBuilder = ContainerConfig.builder();
    if (StringUtils.isNotBlank(request.properties().get("Command"))) {
        containerConfigBuilder.cmd(splitIntoLinesAndTrimSpaces(request.properties().get("Command")).toArray(new String[]{}));
    }

    final String hostConfig = request.properties().get("Hosts");

    ContainerConfig containerConfig = containerConfigBuilder
            .image(imageName)
            .labels(labels)
            .env(env)
            .hostConfig(HostConfig.builder().extraHosts(new Hosts(hostConfig)).build())
            .build();

    ContainerCreation container = docker.createContainer(containerConfig, containerName);
    String id = container.id();

    ContainerInfo containerInfo = docker.inspectContainer(id);

    LOG.debug("Created container " + containerName);
    docker.startContainer(containerName);
    LOG.debug("container " + containerName + " started");
    return new DockerContainer(containerName, containerInfo.created(), request.properties(), request.environment());
}
 
開發者ID:gocd-contrib,項目名稱:docker-elastic-agents,代碼行數:39,代碼來源:DockerContainer.java

示例6: failsafeDockerPull

import com.spotify.docker.client.DockerClient; //導入方法依賴的package包/類
private void failsafeDockerPull(DockerClient docker, String image) {
    try {
        docker.pull(image);
    } catch (Exception e) {
        logger.error("Docker image " + image + " could not be pulled from DockerHub", e);
    }
}
 
開發者ID:alphagov,項目名稱:pay-adminusers,代碼行數:8,代碼來源:PostgresContainer.java

示例7: startContainer

import com.spotify.docker.client.DockerClient; //導入方法依賴的package包/類
private void startContainer() throws Exception {
    final DockerClient dockerClient = DefaultDockerClient.fromEnv().build();
    logger.info("Pulling image spotify/kafka");
    dockerClient.pull("spotify/kafka");
    final String[] ports = {"2181", "9092"};
    List<String> env = new ArrayList<>();
    env.add("ADVERTISED_PORT=9092");
    env.add("ADVERTISED_HOST=192.168.59.103");

    final Map<String, List<PortBinding>> portBindings = new HashMap<>();
    for (String port : ports) {
        List<PortBinding> hostPorts = new ArrayList<>();
        hostPorts.add(PortBinding.of("0.0.0.0", port));
        portBindings.put(port, hostPorts);
    }
    final HostConfig hostConfig = HostConfig.builder().portBindings(portBindings).build();

    final ContainerConfig containerConfig = ContainerConfig.builder()
            .hostConfig(hostConfig)
            .image("spotify/kafka")
            .exposedPorts(ports)
            .env(env)
            .build();

    final ContainerCreation creation = dockerClient.createContainer(containerConfig);
    containerId = creation.id();
    logger.info("Starting container");

    // Start container
    dockerClient.startContainer(containerId);
}
 
開發者ID:SaschaMoellering,項目名稱:ingestion-service,代碼行數:32,代碼來源:KafkaKinesisIntegrationTest.java

示例8: foo

import com.spotify.docker.client.DockerClient; //導入方法依賴的package包/類
private static void foo() throws Exception {
    boolean debug = Boolean.parseBoolean(System.getProperty("debug", "false"));
    String dockerHost = String.format("http://%s:%d", CENTOS, 2375);
    DockerClient docker = null;
    try {
        docker = DefaultDockerClient.builder()
            .uri(dockerHost).build();
        Info info = docker.info();
        System.err.println("Information : " + info);
        if (debug) {
            docker.pull(SELENIUM_STANDALONE_CHROME, new LoggingBuildHandler());
        } else {
            docker.pull(SELENIUM_STANDALONE_CHROME);
        }
        final ImageInfo imageInfo = docker.inspectImage(SELENIUM_STANDALONE_CHROME);
        System.err.println("Information : " + imageInfo);
        // Bind container ports to host ports
        //            final String[] ports = {Integer.toString(PortProber.findFreePort())};
        final String[] ports = {"4444"};
        final Map<String, List<PortBinding>> portBindings = new HashMap<>();
        for (String port : ports) {
            List<PortBinding> hostPorts = new ArrayList<>();
            hostPorts.add(PortBinding.of("0.0.0.0", PortProber.findFreePort()));
            portBindings.put(port, hostPorts);
        }
        //            // Bind container port 443 to an automatically allocated available host port.
        //            List<PortBinding> randomPort = new ArrayList<>();
        //            randomPort.add(PortBinding.randomPort("0.0.0.0"));
        //            portBindings.put("443", randomPort);

        System.err.println("Printing the port mappings : " + portBindings);

        final HostConfig hostConfig = HostConfig.builder().portBindings(portBindings).build();

        final ContainerConfig containerConfig = ContainerConfig.builder()
            .hostConfig(hostConfig)
            .image(SELENIUM_STANDALONE_CHROME).exposedPorts(ports)
            .build();

        final ContainerCreation creation = docker.createContainer(containerConfig);
        final String id = creation.id();

        // Inspect container
        final ContainerInfo containerInfo = docker.inspectContainer(id);
        System.err.println("Container Information " + containerInfo);
        String msg = "Checking to see if the container with id [" + id + "] and name [" +
            containerInfo.name() + "]...";
        System.err.println(msg);
        if (! containerInfo.state().running()) {
            // Start container
            docker.startContainer(id);
            System.err.println(containerInfo.name() + " is now running.");
        } else {
            System.err.println(containerInfo.name() + " was already running.");
        }

        System.err.println("Lets wait here !!!");
    } finally {
        if (docker != null) {
            docker.close();
        }
    }
}
 
開發者ID:RationaleEmotions,項目名稱:just-ask,代碼行數:64,代碼來源:DockerSample.java


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