private void putImageInRegistry() throws InterruptedException { // It doesn't matter which image we use for this test, but use one that's likely to have been pulled already final String dummySourceImage = TestcontainersConfiguration.getInstance().getRyukImage(); client.pullImageCmd(dummySourceImage) .exec(new PullImageResultCallback()) .awaitCompletion(1, TimeUnit.MINUTES); final String id = client.inspectImageCmd(dummySourceImage) .exec() .getId(); // push the image to the registry client.tagImageCmd(id, testImageName, "latest").exec(); client.pushImageCmd(testImageNameWithTag) .exec(new PushImageResultCallback()) .awaitCompletion(1, TimeUnit.MINUTES); // remove the image tag from local docker so that it must be pulled before use client.removeImageCmd(testImageNameWithTag).withForce(true).exec(); } }
public boolean existsImage(String imageName) { boolean exists = true; try { getClient().inspectImageCmd(imageName).exec(); log.trace("Image {} exists", imageName); } catch (NotFoundException e) { log.trace("Image {} does not exist", imageName); exists = false; } return exists; }
public boolean existsImage(String imageName) { boolean exists = true; try { getClient().inspectImageCmd(imageName).exec(); log.trace("Image {} exists", imageName); } catch (NotFoundException e) { log.trace("Image {} does not exist", imageName); exists = false; } return exists; }
public ImageAssert image(String image) { InspectImageResponse imageInfo = this.client.inspectImageCmd(image).exec(); return new ImageAssert(imageInfo); }
private Optional<InspectImageResponse> inspectImage(DockerImage dockerImage) { try { return Optional.of(dockerClient.inspectImageCmd(dockerImage.asString()).exec()); } catch (NotFoundException e) { return Optional.empty(); } catch (RuntimeException e) { numberOfDockerDaemonFails.add(); throw new DockerException("Failed to inspect image '" + dockerImage.asString() + "'", e); } }
private void executeOnDocker(Run<?, ?> build, PrintStream llog, String xImage, String xCommand, String xHostname, DockerClient client) throws DockerException { try { client.inspectImageCmd(xImage).exec(); } catch (NotFoundException e) { throw new DockerClientException("Failed to pull image: " + image, e); } DockerTemplateBase template = new DockerSimpleTemplate(xImage, pullCredentialsId, dnsString, network, xCommand, volumesString, volumesFrom, environmentsString, xHostname, memoryLimit, memorySwap, cpuShares, shmSize, bindPorts, bindAllPorts, privileged, tty, macAddress, null); LOG.info("Starting container for image {}", xImage); llog.println("Starting container for image " + xImage); String containerId = DockerCloud.runContainer(template, client); LOG.info("Started container {}", containerId); llog.println("Started container " + containerId); getLaunchAction(build).started(client, containerId); }
/** * Get image Id from imageTag using DockerBuildInfoHelper client. * * @param imageTag * @param host * @return */ public static String getImageIdFromTag(String imageTag, String host) throws IOException { DockerClient dockerClient = null; try { dockerClient = getDockerClient(host); return dockerClient.inspectImageCmd(imageTag).exec().getId(); } finally { closeQuietly(dockerClient); } }
/** * Get parent digest of an image. * * @param digest * @param host * @return */ public static String getParentId(String digest, String host) throws IOException { DockerClient dockerClient = null; try { dockerClient = getDockerClient(host); return dockerClient.inspectImageCmd(digest).exec().getParent(); } finally { closeQuietly(dockerClient); } }
private void ensureImageExists(String wantedImage) { try { dockerClient.inspectImageCmd(wantedImage).exec(); } catch (NotFoundException e) { dockerClient.pullImageCmd(wantedImage).exec(new PullImageResultCallback()).awaitSuccess(); } } }
protected void pullImage(DockerClient dockerClient) throws InterruptedException { try { // Pulling from remote is always slower than pulling from local try { dockerClient.inspectImageCmd(properties.getDockerImage()).exec(); } catch (NotFoundException e) { dockerClient.pullImageCmd(properties.getDockerImage()).exec(new PullImageResultCallback()).awaitCompletion(); } } // Ignore registry-problems and try to proceed with local image catch (InternalServerErrorException e) { log.warn("Failed to pull image from registry. Try to proceed with local image..", e); } }
result = client.inspectImageCmd(image).exec(); } catch (NotFoundException e) { throw new DockerClientException("Could not pull image: " + image, e);
public boolean shouldPullImage(DockerClient client, String image) { // simply check without asking docker if (pullIfExists(image) && pullIfNotExists(image)) { return true; } if (!pullIfExists(image) && !pullIfNotExists(image)) { return false; } boolean imageExists; try { client.inspectImageCmd(image).exec(); imageExists = true; } catch (NotFoundException e) { imageExists = false; } return imageExists ? pullIfExists(image) : pullIfNotExists(image); } }
private void ensureImageExists(String wantedImage) { try { dockerClient.inspectImageCmd(wantedImage).exec(); } catch (NotFoundException e) { dockerClient.pullImageCmd(wantedImage).exec(new PullImageResultCallback()).awaitSuccess(); } }
@BeforeEach public void ensureContainerIsNotPresent() { try { String imageToRemove = dockerClient.inspectImageCmd(WANTED_IMAGE).exec().getId(); dockerClient.removeImageCmd(imageToRemove).exec(); } catch (NotFoundException e) { // not found, no problems } }
final String imageNameWithVer = imageName() + ":" + this.version; try { Docker.CLIENT.inspectImageCmd(imageNameWithVer).exec(); } catch (final NotFoundException e) { Docker.CLIENT
break; case INSPECT_IMAGE: result = executeInspectImageRequest(client, message).exec(); break; case LIST_IMAGES: