Fabric8 docker-maven-plugin unable set labels to an image Fabric8 docker-maven-plugin unable set labels to an image docker docker

Fabric8 docker-maven-plugin unable set labels to an image


After looking into Build Configuration, of maven-docker-plugin, there is a buildOptions property that also could be used.

The buildOptions also states

These options map to the ones listed as query parameters in the Docker Remote API

The query parameters in Docker Remote API has labels as a parameter.

labels: Arbitrary key/value labels to set on the image, as a JSON map of string pairs.

So we have to specify a JSON string into build options as shown below

<configuration>          <verbose>build</verbose>          <images>            <image>              <name>${container.nameWithTag}</name>              <build>                <contextDir>${project.basedir}/src/main/docker</contextDir>                <buildOptions>                  <labels>{                    "org.label-schema.name":"${container.name}",                    "org.label-schema.description":"My Image",                    "org.label-schema.vcs-url":"${project.scm.url}",                    "org.label-schema.vendor":"Test Vendor",                    "org.label-schema.version":"${container.tag}"                    }</labels>                </buildOptions>              </build>            </image>          </images>        </configuration>