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(); } }
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.TagImageCmd tagImageCmd(final java.lang.String arg0, final java.lang.String arg1, final java.lang.String arg2) { return this.wrappedClient.tagImageCmd(arg0, arg1, arg2); }
@Override public TagImageCmd tagImageCmd(String arg0, String arg1, String arg2) { return getDelegate().tagImageCmd(arg0, arg1, arg2); }
public Void call() throws Exception { DockerClient client = DockerCommand.getClient(descriptor, cfgData.dockerUrlRes, cfgData.dockerVersionRes, cfgData.dockerCertPathRes, null); client.tagImageCmd(imageRes, repositoryRes, tagRes).withForce(withForce).exec(); return null; }
/** * Produces a tag image request * * @param client * @param message * @return */ private TagImageCmd executeTagImageRequest(DockerClient client, Message message) { LOGGER.debug("Executing Docker Tag Image Request"); String imageId = DockerHelper.getProperty(DockerConstants.DOCKER_IMAGE_ID, configuration, message, String.class); String repository = DockerHelper.getProperty(DockerConstants.DOCKER_REPOSITORY, configuration, message, String.class); String tag = DockerHelper.getProperty(DockerConstants.DOCKER_TAG, configuration, message, String.class); if (imageId == null || repository == null || tag == null) { throw new IllegalArgumentException("ImageId, repository and tag must be specified"); } TagImageCmd tagImageCmd = client.tagImageCmd(imageId, repository, tag); Boolean force = DockerHelper.getProperty(DockerConstants.DOCKER_FORCE, configuration, message, Boolean.class); if (force != null) { tagImageCmd.withForce(force); } return tagImageCmd; }
String repositoryName = otherTag.substring(0, lastIndexOfColon); String tagName = otherTag.substring(lastIndexOfColon + 1); docker.tagImageCmd(imageId, repositoryName, tagName).withForce().exec();
final String commitTag = StringUtils.isEmpty(reposTag.tag) ? "latest" : reposTag.tag; client.tagImageCmd(tag_image, reposTag.repos, commitTag).withForce().exec();
final String commitTag = isEmpty(reposTag.tag) ? "latest" : reposTag.tag; log("Tagging built image with " + reposTag.repos + ":" + commitTag); client.tagImageCmd(imageId, reposTag.repos, commitTag).withForce().exec();