Java Code Examples for com.github.dockerjava.api.model.Image#getRepoTags()
The following examples show how to use
com.github.dockerjava.api.model.Image#getRepoTags() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DockerUtil.java From julongchain with Apache License 2.0 | 6 votes |
/** * list images * * @param imageName 镜像名称 * @return */ public static List<String> listImages(String imageName) { logger.info("list images:" + imageName); List<String> imageNameList = new ArrayList<String>(); DockerClient dockerClient = getDockerClient(); List<Image> imageList = dockerClient.listImagesCmd().exec(); for (Image image : imageList) { if (image.getRepoTags() == null) { continue; } String imageTag = image.getRepoTags()[0]; if (StringUtils.isEmpty(imageName) || StringUtils.contains(imageTag, imageName)) { imageNameList.add(imageTag); } } closeDockerClient(dockerClient); return imageNameList; }
Example 2
Source File: AbstractContainer.java From minimesos with Apache License 2.0 | 6 votes |
protected Boolean imageExists(String imageName, String registryTag) { List<Image> images = DockerClientFactory.build().listImagesCmd().exec(); if (images.isEmpty()) { throw new MinimesosException("Failed to find image '" + imageName + ":" + registryTag + ". No images found"); } for (Image image : images) { if (image.getRepoTags() == null) { continue; } for (String repoTag : image.getRepoTags()) { if (repoTag.equals(imageName + ":" + registryTag)) { return true; } } } return false; }
Example 3
Source File: DockerUtils.java From roboconf-platform with Apache License 2.0 | 6 votes |
/** * Finds an image by tag. * @param imageTag the image tag (not null) * @param images a non-null list of images * @return an image, or null if none was found */ public static Image findImageByTag( String imageTag, List<Image> images ) { Image result = null; for( Image img : images ) { String[] tags = img.getRepoTags(); if( tags == null ) continue; for( String s : tags ) { if( s.contains( imageTag )) { result = img; break; } } } return result; }
Example 4
Source File: DockerImageGarbageCollector.java From vespa with Apache License 2.0 | 5 votes |
/** * Returns list of references to given image, preferring image tag(s), if any exist. * * If image is untagged, its ID is returned instead. */ private static List<String> referencesOf(Image image) { if (image.getRepoTags() == null) { return List.of(image.getId()); } return Arrays.stream(image.getRepoTags()) // Docker API returns untagged images as having the tag "<none>:<none>". .map(tag -> { if ("<none>:<none>".equals(tag)) return image.getId(); return tag; }) .collect(Collectors.toUnmodifiableList()); }
Example 5
Source File: DockerfileFixture.java From docker-java with Apache License 2.0 | 4 votes |
public void open() throws Exception { LOGGER.info("building {}", directory); client.buildImageCmd(new File("src/test/resources", directory)).withNoCache(true) .start().awaitImageId(); Image lastCreatedImage = client.listImagesCmd().exec().get(0); repository = lastCreatedImage.getRepoTags()[0]; LOGGER.info("created {} {}", lastCreatedImage.getId(), repository); containerId = client.createContainerCmd(lastCreatedImage.getId()).exec().getId(); LOGGER.info("starting {}", containerId); client.startContainerCmd(containerId).exec(); }