当前位置: 首页>>代码示例>>Java>>正文


Java Info.getImages方法代码示例

本文整理汇总了Java中com.github.dockerjava.api.model.Info.getImages方法的典型用法代码示例。如果您正苦于以下问题:Java Info.getImages方法的具体用法?Java Info.getImages怎么用?Java Info.getImages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.dockerjava.api.model.Info的用法示例。


在下文中一共展示了Info.getImages方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: pullImage

import com.github.dockerjava.api.model.Info; //导入方法依赖的package包/类
/**
 * Pulls the Docker image, whose name matches the String
 * passed as a parameter, from the repository.
 * @param imageName docker image to be pulled
 */
public void pullImage(String imageName) {
	Info info = getLocalDockerInfo();

	int imgCount = info.getImages();
	LOG.info("imgCount1: {}", imgCount);

	//If the image already exists, remove it first
	removeImage(imageName);

	info = dockerClient.infoCmd().exec();
	LOG.info("Client info: {}", info.toString());
	imgCount = info.getImages();
	LOG.info("imgCount2: {}", imgCount);
	LOG.info("Pulling image: {}", imageName);

	InputStream response = dockerClient.pullImageCmd(imageName).exec();
	System.out.println(responseAsString(response));

	info = dockerClient.infoCmd().exec();
	LOG.info("Client info after pull, {}", info.toString());

	InspectImageResponse inspectImageResponse = dockerClient
			.inspectImageCmd(imageName).exec();
	LOG.info("Image Inspect: {}", inspectImageResponse.toString());
}
 
开发者ID:DePaul2015SEStudioTeam1,项目名称:agent,代码行数:31,代码来源:LocalDockerService.java

示例2: testPullImage

import com.github.dockerjava.api.model.Info; //导入方法依赖的package包/类
@Test
public void testPullImage() throws Exception {
    Info info = dockerRule.getClient().infoCmd().exec();
    LOG.info("Client info: {}", info.toString());

    int imgCount = info.getImages();
    LOG.info("imgCount1: {}", imgCount);

    // This should be an image that is not used by other repositories
    // already
    // pulled down, preferably small in size. If tag is not used pull will
    // download all images in that repository but tmpImgs will only
    // deleted 'latest' image but not images with other tags
    String testImage = "hackmann/empty";

    LOG.info("Removing image: {}", testImage);

    try {
        dockerRule.getClient().removeImageCmd(testImage).withForce(true).exec();
    } catch (NotFoundException e) {
        // just ignore if not exist
    }

    info = dockerRule.getClient().infoCmd().exec();
    LOG.info("Client info: {}", info.toString());

    imgCount = info.getImages();
    LOG.info("imgCount2: {}", imgCount);

    LOG.info("Pulling image: {}", testImage);

    dockerRule.getClient().pullImageCmd(testImage)
            .exec(new PullImageResultCallback())
            .awaitCompletion(30, TimeUnit.SECONDS);

    info = dockerRule.getClient().infoCmd().exec();
    LOG.info("Client info after pull, {}", info.toString());

    assertThat(imgCount, lessThanOrEqualTo(info.getImages()));

    InspectImageResponse inspectImageResponse = dockerRule.getClient().inspectImageCmd(testImage).exec();
    LOG.info("Image Inspect: {}", inspectImageResponse.toString());
    assertThat(inspectImageResponse, notNullValue());
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:45,代码来源:PullImageCmdIT.java


注:本文中的com.github.dockerjava.api.model.Info.getImages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。