gradle-docker-plugin icon indicating copy to clipboard operation
gradle-docker-plugin copied to clipboard

Support for full retagging

Open hmigneron opened this issue 2 years ago • 1 comments

Currently the plugin's tagging behavior doesn't allow users to rename the whole image. For example, with the docker tag command, it's possible to do :

docker tag IMAGE1[:TAG1] IMAGE2[:TAG2]

which is currently not possible with the plugin.

Expected Behavior

If would be great if the DockerTagImage task type allowed the equivalent docker tag command

Current Behavior

Not possible to retag image1 to image2 only add new tag to image1, throws error

Context

We work with a "bootstrapper" image that then gets "renamed" (or tagged) into many different images. We would like to do the equivalent of :

docker build -t gcr.io/boostrapper-image-name:v1.0.0 .
docker tag gcr.io/boostrapper-image-name:v1.0.0 gcr.io/first-image-name:v1.0.0
docker tag gcr.io/boostrapper-image-name:v1.0.0 gcr.io/second-image-name:v1.0.0
docker tag gcr.io/boostrapper-image-name:v1.0.0 gcr.io/third-image-name:v1.0.0
...

through multiple uses of the DockerTagImage (or a different task type)

Steps to Reproduce (for bugs)

Simply creating a task with type DockerTagImage is enough to reproduce

Your Environment

Not relevant

hmigneron avatar Jul 11 '22 15:07 hmigneron

The implementation of DockerTagImage would have to be changed similar to DockerPushImage.

@Input
final Property<String> repository = project.objects.property(String)

@Override
void runRemoteCommand() {
    if (images.get().empty) {
        throw new GradleException('No images configured for tag operation.')
    }

    for (String image : images.get()) { ... }
}

Would you be interested in providing a pull request for it? This would be a breaking changes so we'd have to release with the next major version of the plugin.

bmuschko avatar Jul 30 '22 02:07 bmuschko

I am closing this issue. Let me know if you have the bandwidth to implement a pull request.

bmuschko avatar Aug 18 '22 15:08 bmuschko

Will do. Sorry I meant to follow up when you asked for a PR.

hmigneron avatar Aug 18 '22 15:08 hmigneron