/** * Check whether the image is available locally and pull it otherwise */ public void checkAndPullImage(DockerClient client, String image) { List<Image> images = client.listImagesCmd().withImageNameFilter(image).exec(); if (images.isEmpty()) { client.pullImageCmd(image).exec(new PullImageResultCallback()).awaitSuccess(); } }
final PullImageResultCallback callback = new PullImageResultCallback(); dockerClient .pullImageCmd(imageName.getUnversionedPart()) .withTag(imageName.getVersionPart()) .exec(callback);
private void tagImage(String sourceImage, String targetImage, String targetTag) throws InterruptedException { DockerClient client = DockerClientFactory.instance().client(); client.pullImageCmd(sourceImage).exec(new PullImageResultCallback()).awaitCompletion(); client.tagImageCmd(sourceImage, targetImage, targetTag).exec(); } }
public void pull(String image) { log.info("Pull Image " + image + " Start"); try { docker .pullImageCmd(image) .exec(new PullImageProcess()) .awaitCompletion(); } catch (InterruptedException e) { log.error("Pull Image Error", e); throw new PluginException("Pull Image Error"); } log.info("Pull Image " + image + " Success"); }
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(); } }
@java.lang.SuppressWarnings("all") public com.github.dockerjava.api.command.PullImageCmd pullImageCmd(final java.lang.String arg0) { return this.wrappedClient.pullImageCmd(arg0); }
@Override public PullImageCmd pullImageCmd(String arg0) { return getDelegate().pullImageCmd(arg0); }
@Override public void pullImage() { dockerClient.pullImageCmd(TEST_CONFIG.getSchedulerImageName()); }
public void pullImage(String image){ dockerClient.pullImageCmd(image).exec(); }
public void pullImageIfNecessary(String imageId, boolean force) { if (imageId.isEmpty()) { return; } if (force || !existsImage(imageId)) { log.debug("Pulling Docker image {} ... please be patient until the process finishes", imageId); try { getClient().pullImageCmd(imageId).exec(new PullImageResultCallback()).awaitCompletion(); } catch (Exception e) { log.warn("Exception pulling image {}", imageId, e); } log.debug("Image {} downloaded", imageId); } else { log.debug("Image {} already exists", imageId); } }
public void pullImageIfNecessary(String imageId, boolean force) { if (imageId.isEmpty()) { return; } if (force || !existsImage(imageId)) { log.debug("Pulling Docker image {} ... please be patient until the process finishes", imageId); try { getClient().pullImageCmd(imageId).exec(new PullImageResultCallback()).awaitCompletion(); } catch (Exception e) { log.warn("Exception pulling image {}", imageId, e); } log.debug("Image {} downloaded", imageId); } else { log.debug("Image {} already exists", imageId); } }
private void pullImageIfNeeded() { final List<Image> images = client.listImagesCmd().withImageNameFilter(image).exec(); if (images.isEmpty()) { log.info("Pulling " + image); final String[] parts = image.split(":"); client.pullImageCmd(parts[0]).withTag(parts[1]).exec(new PullImageResultCallback()).awaitSuccess(); log.info(image + " pulled"); } }
public void pullImage(String imageName) { this.readWriteLock.readLock().lock(); try { final Image image = Image.valueOf(imageName); PullImageCmd pullImageCmd = this.dockerClient.pullImageCmd(image.getName()); String tag = image.getTag(); if (tag != null && !"".equals(tag)) { pullImageCmd.withTag(tag); } else { pullImageCmd.withTag("latest"); } pullImageCmd.exec(new PullImageResultCallback()).awaitSuccess(); } finally { this.readWriteLock.readLock().unlock(); } }
public void pullImage(String imageName) { this.readWriteLock.readLock().lock(); try { final Image image = Image.valueOf(imageName); PullImageCmd pullImageCmd = this.dockerClient.pullImageCmd(image.getName()); String tag = image.getTag(); if (tag != null && !"".equals(tag)) { pullImageCmd.withTag(tag); } else { pullImageCmd.withTag("latest"); } pullImageCmd.exec(new PullImageResultCallback()).awaitSuccess(); } finally { this.readWriteLock.readLock().unlock(); } }
/** * Check whether the image is available locally and pull it otherwise */ public void checkAndPullImage(DockerClient client, String image) { List<Image> images = client.listImagesCmd().withImageNameFilter(image).exec(); if (images.isEmpty()) { client.pullImageCmd(image).exec(new PullImageResultCallback()).awaitSuccess(); } }
@Override public boolean pullImageAsyncIfNeeded(DockerImage image) { try { synchronized (monitor) { if (scheduledPulls.contains(image)) return true; if (imageIsDownloaded(image)) return false; scheduledPulls.add(image); logger.log(LogLevel.INFO, "Starting download of " + image.asString()); dockerClient.pullImageCmd(image.asString()).exec(new ImagePullCallback(image)); return true; } } catch (RuntimeException e) { numberOfDockerDaemonFails.add(); throw new DockerException("Failed to pull image '" + image.asString() + "'", e); } }
/** * Pulls a Docker image with given name and version. Throws exception when it times out after given timeout. * * @param imageName image to pull * @param imageVersion image version to pull * @param timeoutSecs pulling timeout in seconds */ public static void pullImage(String imageName, String imageVersion, long timeoutSecs) { try { final CompletableFuture<Void> result = new CompletableFuture<>(); DockerClientFactory.build().pullImageCmd(imageName).withTag(imageVersion).exec(new PullImageResultCallback()).awaitCompletion(); } catch (InterruptedException | RuntimeException e) { throw new MinimesosException("Error pulling image or image not found in registry: " + imageName + ":" + imageVersion, e); } }
public Void call() throws Exception { final ConsoleLogger console = new ConsoleLogger(listener); DockerClient client = DockerCommand.getClient(descriptor, cfgData.dockerUrlRes, cfgData.dockerVersionRes, cfgData.dockerCertPathRes, authConfig); PullImageCmd pullImageCmd = client.pullImageCmd(fromImageRes); PullImageResultCallback callback = new PullImageResultCallback() { @Override public void onNext(PullResponseItem item) { console.logInfo(item.toString()); super.onNext(item); } @Override public void onError(Throwable throwable) { console.logError("Failed to exec start:" + throwable.getMessage()); super.onError(throwable); } }; pullImageCmd.exec(callback).awaitSuccess(); return null; }
private void ensureImageExists(String wantedImage) { try { dockerClient.inspectImageCmd(wantedImage).exec(); } catch (NotFoundException e) { dockerClient.pullImageCmd(wantedImage).exec(new PullImageResultCallback()).awaitSuccess(); } } }
private void ensureImageExists(String wantedImage) { try { dockerClient.inspectImageCmd(wantedImage).exec(); } catch (NotFoundException e) { dockerClient.pullImageCmd(wantedImage).exec(new PullImageResultCallback()).awaitSuccess(); } }