use of com.github.dockerjava.api.command.PullImageResultCallback in project appstore-be by EdgeGallery.
the class AppService method downloadAppImage.
/**
* Downloads app image from repo.
*
* @param imageInfoList list of images
*/
public void downloadAppImage(List<SwImgDesc> imageInfoList) {
String[] sourceRepoHost;
for (SwImgDesc imageInfo : imageInfoList) {
LOGGER.info("Download docker image {} ", imageInfo.getSwImage());
sourceRepoHost = imageInfo.getSwImage().split("/");
DockerClient dockerClient = getDockerClient(sourceRepoHost[0], devRepoUsername, devRepoPassword);
try {
dockerClient.pullImageCmd(imageInfo.getSwImage()).exec(new PullImageResultCallback()).awaitCompletion();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOGGER.error("Failed to pull image {}, errorMsg: {}", imageInfo.getSwImage(), e.getMessage());
throw new AppException(PULL_IMAGE_ERR_MESSAGES, ResponseConst.RET_PULL_IMAGE_FAILED, imageInfo.getSwImage());
} catch (Exception e) {
LOGGER.error("failed to download image {}, image not found in repository, {}", imageInfo.getSwImage(), e.getMessage());
throw new AppException(PULL_IMAGE_ERR_MESSAGES, ResponseConst.RET_PULL_IMAGE_FAILED, imageInfo.getSwImage());
}
}
LOGGER.info("images to edge repo downloaded successfully");
}
use of com.github.dockerjava.api.command.PullImageResultCallback in project blackduck-docker-inspector by blackducksoftware.
the class DockerClientManager method pullImage.
private String pullImage(String imageName, String tagName, PullImageCmd pull) throws IntegrationException, InterruptedException {
try {
pull.exec(new PullImageResultCallback()).awaitCompletion();
} catch (NotFoundException e) {
throw new BlackDuckIntegrationException(String.format("Pull failed: Image %s:%s not found. Please check the image name/tag. Error: %s", imageName, tagName, e.getMessage()), e);
}
Optional<Image> justPulledImage = getLocalImage(dockerClient, imageName, tagName);
if (!justPulledImage.isPresent()) {
String msg = String.format("Pulled image %s:%s not found in image list.", imageName, tagName);
logger.error(msg);
throw new BlackDuckIntegrationException(msg);
}
return justPulledImage.get().getId();
}
use of com.github.dockerjava.api.command.PullImageResultCallback in project testcontainers-java by testcontainers.
the class ImagePullPolicyTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
String testRegistryAddress = registry.getEndpoint();
String testImageName = testRegistryAddress + "/image-pull-policy-test";
String tag = UUID.randomUUID().toString();
imageName = DockerImageName.parse(testImageName).withTag(tag);
DockerClient client = DockerClientFactory.instance().client();
String dummySourceImage = "hello-world:latest";
client.pullImageCmd(dummySourceImage).exec(new PullImageResultCallback()).awaitCompletion();
String dummyImageId = client.inspectImageCmd(dummySourceImage).exec().getId();
// push the image to the registry
client.tagImageCmd(dummyImageId, testImageName, tag).exec();
client.pushImageCmd(imageName.asCanonicalNameString()).exec(new ResultCallback.Adapter<>()).awaitCompletion(1, TimeUnit.MINUTES);
}
use of com.github.dockerjava.api.command.PullImageResultCallback in project testcontainers-java by testcontainers.
the class DockerRegistryContainer method createImage.
@SneakyThrows(InterruptedException.class)
public DockerImageName createImage(String originalImage, String tag) {
DockerClient client = getDockerClient();
client.pullImageCmd(originalImage).exec(new PullImageResultCallback()).awaitCompletion();
String dummyImageId = client.inspectImageCmd(originalImage).exec().getId();
DockerImageName imageName = DockerImageName.parse(getEndpoint() + "/" + Base58.randomString(6).toLowerCase()).withTag(tag);
// push the image to the registry
client.tagImageCmd(dummyImageId, imageName.asCanonicalNameString(), tag).exec();
client.pushImageCmd(imageName.asCanonicalNameString()).exec(new ResultCallback.Adapter<>()).awaitCompletion(1, TimeUnit.MINUTES);
// Remove from local cache, tests should pull the image themselves
client.removeImageCmd(imageName.asCanonicalNameString()).exec();
return imageName;
}
use of com.github.dockerjava.api.command.PullImageResultCallback in project synopsys-detect by blackducksoftware.
the class PullDockerImageProvider method installImage.
@Override
public void installImage(String imageName, DockerClient dockerClient) throws InterruptedException {
PullImageResultCallback callback = new PullImageResultCallback();
// I am not sure this is right, it says 'repository' in the args.
dockerClient.pullImageCmd(imageName).exec(callback);
callback.awaitCompletion();
}
Aggregations