@Override protected Void execute(TagImageCmd command) { WebTarget webTarget = getBaseResource().path("/images/" + command.getImageId() + "/tag") .queryParam("repo", command.getRepository()).queryParam("tag", command.getTag()); webTarget = booleanQueryParam(webTarget, "force", command.hasForceEnabled()); LOGGER.trace("POST: {}", webTarget); webTarget.request().post(null).close(); return null; }
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(); } }
/** * 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; }
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(); } }
break; case TAG_IMAGE: result = executeTagImageRequest(client, message).exec(); break; case COMMIT_CONTAINER:
@Override protected Void execute(TagImageCmd command) { WebTarget webTarget = getBaseResource().path("/images/" + command.getImageId() + "/tag") .queryParam("repo", command.getRepository()).queryParam("tag", command.getTag()); webTarget = booleanQueryParam(webTarget, "force", command.hasForceEnabled()); LOGGER.trace("POST: {}", webTarget); webTarget.request().post(null); return null; }
@Override protected Void execute(TagImageCmd command) { WebTarget webTarget = getBaseResource().path("/images/" + command.getImageId() + "/tag") .queryParam("repo", command.getRepository()).queryParam("tag", command.getTag()); webTarget = booleanQueryParam(webTarget, "force", command.hasForceEnabled()); LOGGER.trace("POST: {}", webTarget); webTarget.request().post(null).close(); return null; }
@Override protected Void execute(TagImageCmd command) { WebTarget webTarget = getBaseResource().path("/images/" + command.getImageId() + "/tag") .queryParam("repo", command.getRepository()).queryParam("tag", command.getTag()); webTarget = booleanQueryParam(webTarget, "force", command.hasForceEnabled()); LOGGER.trace("POST: {}", webTarget); webTarget.request().post(null); return null; }