Do not tag every image with latest
See original GitHub issueDescription
Currently, every image that is built with d-m-p is automatically tagged with <image_name>:latest. When adding a <tags> section to the <build> section in the pom.xml, the newly built image is additionally tagged with the given tags, but it will still be tagged with latest.
My problem is, when running docker:build and docker:push, both latest and the additional tags will be pushed to the registry. In my case I do not want the latest tag to be pushed, only the additional tags.
I already looked at the source code, unfortunately the tagging with latest is, as far as I can tell, happening in UrlBuilder#buildImage() where a “t” parameter is added to the build command. Therefore it is not possible to disable the tagging with latest without modifying the code of d-m-p.
Info
- d-m-p version : 0.31.0
- Maven version (
mvn -v
) : 3.5.4 - Docker version : Docker version 19.03.1, build 74b1e89e8a
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (1 by maintainers)
No, an image is not unconditionally tagged always with
latest
, you can (and should) specify a tag as part of the image<name>
and only use<tags>
for additional tags.How does you configuration look like ?
@DimitriosSG @rohanKanojia This is the same use case I had in mind with #1495. I even provided a few PRs to change this behaviour, which in the end we had to revert.
There is a simple solution, which is not really documented though (afaik).
When specifying the image name as
name>${docker.name}</name>
, latest is assumed. You can change this behaviour though, by specifying the default tag likename>${docker.name}:${project.version}</name>
. This is what we are using in our projects right now, and works without a flaw.