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(); } }
private void push(Id id) { for (final Identifier identifier : identifiers(id)) { try { final PushImageCmd pushImageCmd = docker.pushImageCmd(identifier.repository.name); if (identifier.tag.isPresent()) { pushImageCmd.withTag(identifier.tag.get()); } logger.info("Pushing " + id + " (" + asString(identifier) + ")"); final PushImageResultCallback callback = new PushImageResultCallback() { public void onNext(final PushResponseItem item) { super.onNext(item); logger.info(buildResponseItemToString(item).replaceAll("\\r?\\n$", "")); } }; pushImageCmd.exec(callback).awaitSuccess(); } catch (DockerException | DockerClientException e) { throw new OrchestrationException(e); } } }
public Void call() throws Exception { final ConsoleLogger console = new ConsoleLogger(listener); DockerClient client = DockerCommand.getClient(descriptor, cfgData.dockerUrlRes, cfgData.dockerVersionRes, cfgData.dockerCertPathRes, authConfig); PushImageCmd pushImageCmd = client.pushImageCmd(imageRes).withTag(tagRes); PushImageResultCallback callback = new PushImageResultCallback() { @Override public void onNext(PushResponseItem 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); } }; pushImageCmd.exec(callback).awaitSuccess(); return null; }
new DockerRegistryEndpoint(registry, pushCredentialsId), run.getParent().getParent()); cmd.exec(resultCallback).awaitSuccess(); } catch (DockerException ex) {
@TaskAction public void runTask() { String dockerUser = getProperty("DOCKER_USER", "docker.user"); String dockerPassword = getProperty("DOCKER_PASSWORD", "docker.password"); String dockerEmail = getProperty("DOCKER_EMAIL", "docker.email"); DockerClient dockerClient = DockerClientBuilder .getInstance(DefaultDockerClientConfig.createDefaultConfigBuilder() .withRegistryUsername(dockerUser) .withRegistryPassword(dockerPassword) .withRegistryEmail(dockerEmail)) .build(); for (String tag : tags) { PushImageCmd pushImageCmd = dockerClient.pushImageCmd(repository); pushImageCmd.withTag(tag).exec(new PushImageResultCallback()).awaitSuccess(); } }
/** * Push docker image using the docker java client. * * @param imageTag * @param username * @param password * @param host */ public static void pushImage(String imageTag, String username, String password, String host) throws IOException { final AuthConfig authConfig = new AuthConfig(); authConfig.withUsername(username); authConfig.withPassword(password); DockerClient dockerClient = null; try { dockerClient = getDockerClient(host); dockerClient.pushImageCmd(imageTag).withAuthConfig(authConfig).exec(new PushImageResultCallback()).awaitSuccess(); } finally { closeQuietly(dockerClient); } }
cmd.exec(resultCallback).awaitSuccess();
result = executePushImageRequest(client, message).exec(new PushImageResultCallback() { @Override public void onNext(PushResponseItem item) {