docker-maven-plugin
docker-maven-plugin copied to clipboard
Can't figure out how to set the image tag
We are using io.fabric8:docker-maven-plugin:0.44.0.
We converted from using the (very) old spotify plugin. We're using the plugin in a relatively simple way, and that's all we need, but there's one thing that we're having trouble figuring out, perhaps because of issues in the documentation, but I'm not sure.
Our main issue right now is that we're unable to figure out how to pass the required image tag on the mvn command line. We've tried setting a couple of different properties that were implied by your documentation, but nothing worked. We've at least been able to hardcode the tag in the plugin definition, but that's just temporary.
The following is our current plugin definition, although I know it has a lot of ignored cruft that we have to clear out. I think it's really only the initial block that is relevant.
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.44.0</version>
<configuration>
<images>
<image>
<name>${docker.registry}/com.att.idp/${serviceArtifactName}</name>
<build>
<dockerFileDir>${project.basedir}/src/main/docker</dockerFileDir>
<tags>
<tag>dev-latest</tag>
</tags>
<filter>@</filter>
</build>
</image>
</images>
<verbose>true</verbose>
<imageName>${docker.registry}/com.att.idp/${serviceArtifactName}</imageName>
<dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
<serverId>docker-hub</serverId>
<registryUrl>https://${docker.registry}</registryUrl>
<imageTags>
<imageTag>${project.version}</imageTag>
<imageTag>dev-latest</imageTag>
</imageTags>
<forceTags>true</forceTags>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>opt/ajsc/etc/config/*</include>
<includes>
<include>**/*</include>
</includes>
</resource>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>prometheus-javaagent.jar</include>
</resource>
</resources>
</configuration>
</plugin>
In my build script, I have a line like this:
... mvn -Ddocker.image.tag="${IMAGE_TAG}" -s $MAVEN_SETTINGS -U docker:build
But this had no effect.
@davidmichaelkarr : Do you want tag value to be configurable via property?
Image name can also include tag part:
<name>${docker.registry}/com.att.idp/${serviceArtifactName}:${yourTagName}</name>
<tags> option that you're using is for additional tag element which you want to add after build
Apart from this, you can also use pre-existing placeholders like %l (latest), %v (project version), %t (timestamp)
The first option is ideal. We will need to be able to set the property used there on the mvn command line.
@davidmichaelkarr : By first option you mean the tag property in image name, right? Is it working if you specify it like this?