In our project we create docker images, push to registry using fabric8
maven plugin. We have a requirement in which we need to find out the details of each image (name, tag , registry pushed to etc) that gets created in the project build.
Is there any out of the box solution in fabric8
for that ? or do we have any java API's of fabric8
available which we can use and integrate in our existing maven plugin to get such info?
As far as I know, there is no way to get such info from the plugin itself. But when building Docker images with fabric8
's docker-maven-plugin
, a hierarchy like the following is created on the target/
folder by default :
target
├── docker
│ ├── build.timestamp
│ └── my
│ └── registry
│ ├── image1
│ │ ├── tag1
│ │ │ ├── build
│ │ │ │ └── Dockerfile
│ │ │ ├── tmp
│ │ │ │ └── docker-build.tar
│ │ │ └── work
│ │ └── tag2
│ │ ├── build
│ │ │ └── Dockerfile
│ │ ├── tmp
│ │ │ └── docker-build.tar
│ │ └── work
│ ├── image2
│ │ ├── tag1
│ │ │ ├── ...
... ... ... ...
In this example, 3 images were built :
my/registry/image1:tag1
my/registry/image1:tag2
my/registry/image2:tag1
So browsing this hierarchy can inform you about the images names, tags and registries. I agree that it is not the cleanest solution.
Alternatively, you can use spotify
's dockerfile-maven-plugin
(https://github.com/spotify/dockerfile-maven), because it creates a docker-info
JAR containing what you're looking for :
META-INF/
META-INF/MANIFEST.MF
META-INF/docker/
META-INF/docker/my/registry/
META-INF/docker/my/registry/image1/
META-INF/docker/my/registry/image1/image-name
META-INF/docker/my/registry/image1/repository
META-INF/docker/my/registry/image1/tag
META-INF/docker/my/registry/image1/image-id
META-INF/maven/
META-INF/maven/my/registry/
META-INF/maven/my/registry/image1/
META-INF/maven/my/registry/image1/pom.xml
META-INF/maven/my/registry/image1/pom.properties
This docker-info
JAR could then be put into a repository manager to help retrieving information about built images, and moreover to version your different builds.