本文整理汇总了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());
}
示例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());
}