• gradle plugin version: id("org.springframework.boot") version "2.7.5"
  • dsl: kotlin
  • snippet:
tasks.bootBuildImage {
  imageName = "sample"
  tags = listOf("tag1", "tag2")
}
  • command: gradle bootBuildImage
  • actual:
Successfully built image 'docker.io/library/sample:latest'
Successfully created image tag 'docker.io/library/tag1'
Successfully created image tag 'docker.io/library/tag2'
  • expected:
Successfully built image 'docker.io/library/sample:latest'
Successfully created image tag 'docker.io/library/sample:tag1'
Successfully created image tag 'docker.io/library/sample:tag2'

Comment From: wilkinsona

We know from #33002 that we have some users who expect the current behaviour. They have configured their tags like this:

bootBuildImage {
    imageName = "eu.gcr.io/company/imagename"
    builder = "paketobuildpacks/builder:tiny"
    if (System.getenv("IMAGE_TAGS")) {
        tags = (System.getenv("IMAGE_TAGS").split(",") as List<String>).collect { "$imageName:$it" }
    }
}

If we change it to work as shown in the expected output above, this configuration snippet would no longer work.

We're also aligned with the pack CLI which describes its --tag option thus:

  -t, --tag strings                 Additional tags to push the output image to.
                                    Tags should be in the format 'image:tag' or 'repository/image:tag'.
                                    Repeat for each tag in order, or supply once by comma-separated list

In our implementation, each tag becomes an ImageReference which means that things are a little more flexible due to its implementation:

Create a new ImageReference from the given value. The following value forms can be used:

  • name (maps to docker.io/library/name)
  • domain/name
  • domain:port/name
  • domain:port/name:tag
  • domain:port/name@digest

I think we should update the Maven and Gradle plugin documentation to describe the behavior of tags in more detail.