I have define this plugin section:
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.17.2</version>
<configuration>
<images>
<image>
<alias>galan</alias>
<name>cdp/galan</name>
<external>
<type>compose</type>
<basedir>docker</basedir>
<composeFile>docker-compose.yml</composeFile>
</external>
</image>
</images>
</configuration>
</plugin>
When I do:
mvn clean docker:build
I get the following error:
[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.17.2:build (default-cli) on project galileo-anagrafica-rapporto-services: Execution default-cli of goal io.fabric8:docker-maven-plugin:0.17.2:build failed: Configuration error: <image> must have a non-null <name> -> [Help 1]
mvn -v) :Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 1.8.0_111, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: it_IT, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-45-generic", arch: "amd64", family: "unix"
Thanks for the bug report.
Any chance that you could share the project so that I could reproduce it ?
I had a similar problem when my docker-compose.yml contained a build instruction. If I just refer to an image everything is fine...
however, I don't understand if all the other configurations work... I tried to wait for a condition in the
I had a same issue. I'm wondering if docker-compose actually works here given it fails with such a simple configuration.
@longtu @LorenzoBettini @mcapitanio thanks for the feedback. It really would help me, if you could share your docker-compose.yml files to reproduce this (as it works for the sample we have in samples/docker-compose, even when I add a build: section.
@rhuss Thanks for your instant reply. Here is my docker-compose file:
version: '2'
services:
mysqlone:
build:
context: .
dockerfile: mySQLDockerfile
ports:
- 33306:3306
volumes:
- /mysql_data
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: database_name
MYSQL_USER: test_user
MYSQL_PASSWORD: test_password
@rhuss sorry, too much time has passed and I don't remember the details... if I'm not wrong, I was not giving any alias, so probably that was the real problem...
Hi,
@rhuss : i have the very same issue with the 0.20.0 version of the plugin.
Any update on the source of the problem ?
@rhuss reproduced same issue in two cases by:
<alias> in the <image>container_name in docker-compose and <name> in pom.xml at the same timeHope this will help.
upd:
for the second case using of
<run>
<namingStrategy>alias</namingStrategy>
</run>
fixes the issue
Simple reproducing case here. Workaround is to include an image along with the build.
Dockerfile:
FROM redis
CMD redis-cli
pom.xml excerpt:
<configuration>
<images>
<image>
<alias>my-redis</alias>
<name>my-redis</name>
<external>
<type>compose</type>
<basedir>.</basedir>
<composeFile>docker-compose.yaml</composeFile>
</external>
</image>
</images>
</configuration>
docker-compose.yaml:
version: '2.1'
services:
my-redis:
build:
context: .
other-redis:
build:
context: .
Out:
$ mvn io.fabric8:docker-maven-plugin:0.22.1:build
...
[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.22.1:build (default-cli) on project sandbox: Execution default-cli of goal io.fabric8:docker-maven-plugin:0.22.1:build failed: Configuration error: <image> must have a non-null <name> -> [Help 1]
...
$ docker --version && docker-compose --version
Docker version 17.09.0-ce, build afdb6d4
docker-compose version 1.16.1, build 6d1ac21
Yep. Looks like I'm affected as well. I debugged plugin code a bit (turns out it's as easy as use mvnDebug instead of mvn on the cmd line):
At least one NPE issue is here io.fabric8.maven.docker.config.handler.compose.DockerComposeConfigHandler#getImageName
My workaround was to set pom.xml/alias to match “name” from docker-compose (for the image that requires a build and is not just pulled so it does not have "image"), then pom.xml/name would be used for that image and it can be non-null.
Unfortunately in my case there were some weird issues around <wait/> configs, so I ended up switching to exec plugin with shell scripts calling docker-compose directly.
Hello everyone.
Unfortunately I encountered the same problem.
Is there already a fix or workaround for the problem?
In addition, I noticed that the plugin unfortunately does not yet support compose files of version 3. Will this be added?
@Vamillion yeah, you right, our compose support needs some polishing and more love. we are all super busy and so compose dropped a bit off. Sorry about that.
Currently, we have no concrete plans for composing version 3 but would be super happy if someone would help with this. We are constantly integration PR (though the queue piled up again a bit, eventually we get them merged more or less all of them).
So if you (or anybody else) feels fancy to polish the compose support, that would be awesome ;-)
@rhuss First of all, thank you very much for your quick reply. I think it's because I'm still a bit fresh on the road with regard to container management with Docker that I can't give you so much help in such a hurry. Should I see anything, however, I will get in touch with you. The same will probably also apply to a workaround for the error described above.
Hello again,
apparently it is because there is no image name listed within the docker-compose.yml.
I don't know, if the guys above checked that out?
I checked that with and without the <name> Tag in the POM.
It seems that only the image name within the compose file is relevant.
I don't know if it's just a workaround, but I'm able to create within Netbeans without any problems.
The dependencies are the following :
<dependency> <groupId>io.fabric8</groupId> <artifactId>run-java-sh</artifactId> <version>1.2.2</version> </dependency>
<image>
<alias>secunym-pss-db</alias>
<!--<name>vamillion/secunym-pss-db:latest</name>-->
<external>
<type>compose</type>
<basedir>${project.basedir}/src/test/resources/docker</basedir>
<composeFile>docker-compose.yml</composeFile>
</external>
</image>
<image>
<alias>secunym-pss-application</alias>
<name>vamillion/secunym-pss-application:latest</name>
<external>
<type>compose</type>
<basedir>${project.basedir}/src/test/resources/docker</basedir>
</external>
In addition a part of the Compose Files:
secunym-dcc-application:
image: xxx/secunym-dcc-application
build:
context: ./dockerDCC/app/
networks:
secunym-systemtest-network:
aliases:
- secunym-dcc-app
ipv4_address: xxx.xxx.xx.xx
ports:
- "28080:8080"
- "28181:8181"
depends_on:
- secunym-dcc-db
Unfortunately networking is not supported by the plugin, so I have to think about something now.
I'm sorry, if the formatting is not correct. I'm new at GitHub and i didn't had the time to check out the manuels.
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:
Most helpful comment
Hi,
@rhuss : i have the very same issue with the 0.20.0 version of the plugin.
Any update on the source of the problem ?