@AfterClass public static void tearDown() { RegistryAuthLocator.setInstance(originalAuthLocatorSingleton); client.removeImageCmd(testImageNameWithTag).withForce(true).exec(); }
@Test public void runCommandInsideDockerShouldNotFailIfImageDoesNotExistsLocally() { final DockerClientFactory dockFactory = DockerClientFactory.instance(); try { //remove tiny image, so it will be pulled during next command run dockFactory.client() .removeImageCmd(TestcontainersConfiguration.getInstance().getTinyImage()) .withForce(true).exec(); } catch (NotFoundException ignored) { // Do not fail if it's not pulled yet } dockFactory.runInsideDocker( cmd -> cmd.withCmd("sh", "-c", "echo 'SUCCESS'"), (client, id) -> client.logContainerCmd(id) .withStdOut(true) .exec(new LogToStringContainerCallback()) .toString() ); }
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 void removeImage(String contaierID, Boolean force) { this.readWriteLock.readLock().lock(); try { this.dockerClient.removeImageCmd(contaierID).withForce(force).exec(); } finally { this.readWriteLock.readLock().unlock(); } }
public void removeImage(String contaierID, Boolean force) { this.readWriteLock.readLock().lock(); try { this.dockerClient.removeImageCmd(contaierID).withForce(force).exec(); } finally { this.readWriteLock.readLock().unlock(); } }
public Void call() throws Exception { DockerClient client = DockerCommand.getClient(descriptor, cfgData.dockerUrlRes, cfgData.dockerVersionRes, cfgData.dockerCertPathRes, null); if (imageIdRes == null || imageIdRes.isEmpty()) { client.removeImageCmd(imageNameRes).exec(); } else { client.removeImageCmd(imageNameRes).withImageId(imageIdRes).exec(); } return null; }
public void removeImageById(String imageId) throws NotFoundException, NotModifiedException { dockerClient.removeImageCmd(imageId).withForce(true).exec(); LoggingService.logInfo(MODULE_NAME, String.format("image \"%s\" removed", imageId)); }
private void cleanImages(String id) throws IOException { try(final DockerClient client = getClient()) { client.removeImageCmd(id) .withForce(true) .exec(); } }
private static void dockerRmi(String imageId) { if (imageId != null) { try { dockerClient.removeImageCmd(imageId).exec(); System.out.printf("cleaned test image %s\n", imageId); } catch (Throwable t) { System.out.printf("Failed to clean test image %s: %s\n", imageId, t.toString()); } } }
private void cleanImage(final Id id, final boolean force) { if (id == null) { throw new IllegalArgumentException("id is null"); } String imageId = null; try { imageId = findImageId(id); } catch (NotFoundException e) { logger.warn("Image " + id + " not found"); } catch (DockerException e) { throw new OrchestrationException(e); } if (imageId != null) { logger.info("Removing image " + imageId); try { docker.removeImageCmd(imageId) .withForce(force) .exec(); } catch (DockerException e) { logger.warn(e.getMessage()); } } }
void deleteImage(DockerImage dockerImage) { try { dockerClient.removeImageCmd(dockerImage.asString()).exec(); } catch (NotFoundException ignored) { // Image was already deleted, ignore } catch (RuntimeException e) { numberOfDockerDaemonFails.add(); throw new DockerException("Failed to delete docker image " + dockerImage.asString(), e); } }
@BeforeEach public void ensureContainerIsNotPresent() { try { String imageToRemove = dockerClient.inspectImageCmd(WANTED_IMAGE).exec().getId(); dockerClient.removeImageCmd(imageToRemove).exec(); } catch (NotFoundException e) { // not found, no problems } }
break; case REMOVE_IMAGE: result = executeRemoveImageRequest(client, message).exec(); break; case SEARCH_IMAGES: