本文整理汇总了Java中com.spotify.docker.client.messages.Image类的典型用法代码示例。如果您正苦于以下问题:Java Image类的具体用法?Java Image怎么用?Java Image使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Image类属于com.spotify.docker.client.messages包,在下文中一共展示了Image类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listImageTags
import com.spotify.docker.client.messages.Image; //导入依赖的package包/类
@Override
public Set<String> listImageTags() throws IOException {
final Set<String> result = new HashSet<>();
try {
for (Image image : CollectionUtils
.nullToEmpty(this.client.listImages())) {
for (String tag : CollectionUtils.nullToEmpty(image.repoTags())) {
if (tag != null) {
result.add(tag);
}
}
}
} catch (DockerException | InterruptedException e) {
throw new IOException(e);
}
return result;
}
示例2: pullImageIfNotExists
import com.spotify.docker.client.messages.Image; //导入依赖的package包/类
@Override
public void pullImageIfNotExists() throws IOException {
try {
for (Image image : nullToEmpty(this.dockerClient.listImages())) {
for (String tag : nullToEmpty(image.repoTags())) {
if (this.dockerImage.equals(tag)) {
return;
}
}
}
getLogger().fine("Pull Docker image: " + this.dockerImage);
this.dockerClient.pull(this.dockerImage);
} catch (InterruptedException | DockerException e) {
throw new IOException(e);
}
}
示例3: start
import com.spotify.docker.client.messages.Image; //导入依赖的package包/类
@Override
public void start(WorkflowInstance workflowInstance, RunSpec runSpec) {
final String imageTag = runSpec.imageName().contains(":")
? runSpec.imageName()
: runSpec.imageName() + ":latest";
final ContainerCreation creation;
try {
boolean found = false;
for (Image image : client.listImages()) {
found |= image.repoTags().contains(imageTag);
}
if (!found) {
client.pull(imageTag, System.out::println); // blocking
}
final ContainerConfig containerConfig = ContainerConfig.builder()
.image(imageTag)
.cmd(runSpec.args())
.build();
creation = client.createContainer(containerConfig, runSpec.executionId());
client.startContainer(creation.id());
} catch (DockerException | InterruptedException e) {
throw new RuntimeException(e);
}
inFlight.put(creation.id(), workflowInstance);
LOG.info("Started container with id " + creation.id() + " and name " + runSpec.executionId());
}
示例4: pullImageIfNeeded
import com.spotify.docker.client.messages.Image; //导入依赖的package包/类
/**
* Pulls the image with the given name if it does not appear in the list of
* available images.
*
* @param imageName
* the name of the image that should be pulled
*/
@SuppressWarnings("unused")
private void pullImageIfNeeded(String imageName) {
// do not pull if env var is set to false
if (!DOCKER_AUTOPULL) {
return;
}
if (!containsVersionTag(imageName)) {
imageName += ":latest";
}
// check if image is already available
try {
List<Image> images = dockerClient.listImages();
for (Image image : images) {
if (image.repoTags() != null) {
for (String tag : image.repoTags()) {
if (tag.equals(imageName)) {
return;
}
}
}
}
// pull image and wait for the pull to finish
pullImage(imageName);
} catch (Exception e) {
LOGGER.error("Exception while pulling the image \"" + imageName + "\". " + e.getClass().getName() + ": "
+ e.getLocalizedMessage());
}
}
示例5: findImageWithTag
import com.spotify.docker.client.messages.Image; //导入依赖的package包/类
protected boolean findImageWithTag(final String id, final List<Image> images) {
if (images != null) {
for (Image image : images) {
if (image.repoTags() != null) {
for (String tag : image.repoTags()) {
if (tag.contains(id)) {
return true;
}
}
}
}
}
return false;
}
示例6: initClient
import com.spotify.docker.client.messages.Image; //导入依赖的package包/类
@Before
public void initClient() throws Exception {
dockerClient = DefaultDockerClient.fromEnv().build();
// check if busybox is present
List<Image> images = dockerClient.listImages(DockerClient.ListImagesParam.allImages());
if (!findImageWithTag(busyboxImageName, images)) {
dockerClient.pull(busyboxImageName);
}
}
示例7: imageAvaliable
import com.spotify.docker.client.messages.Image; //导入依赖的package包/类
private boolean imageAvaliable(DockerClient dockerClient, String imageName) throws DockerException, InterruptedException {
String imageNameWithTag = imageNameWithTag(imageName);
List<Image> listImages = dockerClient.listImages(ListImagesParam.danglingImages(false));
for (Image image : listImages) {
if (image.repoTags() != null && image.repoTags().contains(imageNameWithTag)) {
log.debug("image '{}' found", imageNameWithTag);
return true;
}
}
log.debug("image '{}' not found", imageNameWithTag);
return false;
}
示例8: imageAvaliable
import com.spotify.docker.client.messages.Image; //导入依赖的package包/类
private boolean imageAvaliable(DockerClient dockerClient, String imageNameWithTag) throws DockerException, InterruptedException {
List<Image> listImages = dockerClient.listImages(ListImagesParam.danglingImages(false));
for (Image image : listImages) {
if (image.repoTags() != null && image.repoTags().contains(imageNameWithTag)) {
return true;
}
}
return false;
}
示例9: listImages
import com.spotify.docker.client.messages.Image; //导入依赖的package包/类
@Override
public List<Image> listImages(ListImagesParam... lips) {
throw new IllegalStateException(DISCONNECTED);
}