Having the simple configuration of:
<configuration>
<showLogs>true</showLogs>
<autoCreateCustomNetworks>true</autoCreateCustomNetworks>
<images>
<image>
<alias>database</alias>
<name>database-${env.BRANCH_NAME}-${env.BUILD_ID}</name>
<external>
<type>compose</type>
<basedir>${project.basedir}/docker</basedir>
<composeFile>docker-compose.yml</composeFile>
</external>
<run>
<network>
<mode>custom</mode>
<name>itests-${env.BRANCH_NAME}-${env.BUILD_ID}</name>
<alias>database</alias>
</network>
</run>
</image>
</images>
</configuration>
With docker-compose.yml:
version: '2'
services:
database:
container_name: postgis-${BRANCH_NAME}-${BUILD_ID}
image: custom-registry/postgis:9.6-german-geo
tmpfs:
- /var/lib/postgres
environment:
- POSTGRES_PASSWORD=postgres
Produces the error:
[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.23.0:build (container-setup) on project aloxerv: Execution container-setup of goal io.fabric8:docker-maven-plugin:0.23.0:build failed: Configuration error: <image> must have a non-null <name> -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.fabric8:docker-maven-plugin:0.23.0:build (container-setup) on project aloxerv: Execution container-setup of goal io.fabric8:docker-maven-plugin:0.23.0:build failed: Configuration error: <image> must have a non-null <name>
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution container-setup of goal io.fabric8:docker-maven-plugin:0.23.0:build failed: Configuration error: <image> must have a non-null <name>
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
Caused by: java.lang.IllegalArgumentException: Configuration error: <image> must have a non-null <name>
at io.fabric8.maven.docker.config.ConfigHelper.verifyImageNames(ConfigHelper.java:124)
at io.fabric8.maven.docker.config.ConfigHelper.resolveConfiguration(ConfigHelper.java:114)
at io.fabric8.maven.docker.config.ConfigHelper.resolveImages(ConfigHelper.java:50)
at io.fabric8.maven.docker.AbstractDockerMojo.initImageConfiguration(AbstractDockerMojo.java:307)
at io.fabric8.maven.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:214)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
... 21 more
This appears to be a bug, as clearly the
I encountered exactly the same issue. Also if I remove the external tag then it tries to pull the image with the name as specified in the name tag. So the name tag is at the right place.
I had the same issue. The service name in the docker-compose.xml was wrong and not matching with the maven artifact name. I kept both of them same name and it worked.
docker-compose.xml
services:
some-other-name:
The compose support is a bit behind, so there could be indeed bugs like these. And this is indeed a bug. Anyone wanting to help to analyse and fix the issue ? I can assist with some pointer, but otherwise I have to much on my plate to fix it on my own.
Most helpful comment
I had the same issue. The service name in the docker-compose.xml was wrong and not matching with the maven artifact name. I kept both of them same name and it worked.
docker-compose.xml
services:
some-other-name: