-
Notifications
You must be signed in to change notification settings - Fork 642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ARG not support in FROM #859
Comments
It's only recently that Docker allows parameterization of the image name, and the validation in d-m-p is not updated. As a workaround you could try to set the <properties>
<VERSION>latest</VERSION>
</properties> This will trigger d-m-p to replace all Is this a valid solution for you ? If not, please open an issue for extending the image name validation which is currently solely based on this regexp |
I am unable to use the above as a workaround in the latest version of the plugin
Do you know if this issue will suffice for addressing the problem or do you have a suggestion of what the regex change issue would look like? I would be happy to create that issue if necessary. |
Do you mean that is a regression for you (so, that it had worked previously for you), or does it never had worked ? Could you please post or link a reference project where you see this issue ? |
@rhuss I can confirm that your workaround works. |
This workaround may work but it forces one to mix maven and docker configuration in a rather unfortunate way. We typically perform all configuration of the docker plugin in a common parent pom.xml file. This is possible since the configuration only contains information common to all projects. Specifally, we configure the plugin using maven meta-data such as ${project.version}, and common things like our target registry. This way, maven child projects simply need to use the parent pom.xml file; they don't need to include any configuration related to the docker plugin at all. If we need to include information about the FROM image via maven, then this information needs to be included in each child project pom.xml, since they are based on different images. If ARG was supported in FROM, we could have this information only in the Dockerfiles (which are different anyway), rather than having to modify each child pom.xml file as well. Updating the regex patterns in the ImageName class (e.g. to allow the pattern |
I am experiencing the same issue and while the above workaround does the trick, it's not particularly clean for our set-up. I'm looking into creating a pull request for this but I have some questions about the approach.
docker-maven-plugin/src/main/java/io/fabric8/maven/docker/service/BuildService.java Lines 93 to 116 in d97ea9e
|
@PieterJanVanAeken thanks a lot for your support-offer and sorry for the delayed answer. Indeed the tricky part would be to do the interpolation on our own.
Isn't it the base image's name which need to be substitute not the image name itself, right ? So, when the Dockerfile mode is used then the FROM line should be processed for the base image being able to be pulled.
Yes, the fully mergedBuildMap should be used and could be moved upwards.
Tbh, I would do this replacement with some simple regexp instead of using an interpolation library. The default values need to be respected as well, but that should not be a big issue. |
The issue is related to the pull policy feature, the mojo will query for FROM images in all cases. For users choosing ARGs in FROMs, a workaround could be to have pull policy See
|
Tested with latest 0.31.0 release and had same issue. |
Hi, I found a use case on which I'm not able to use the provided workaround. Basically, I'm trying build two images in the same pom file. Now, even if I put something like Does someone have any idea? |
@KowKiller sorry, there is probably no good easy solution. You could go to use multi-modules (which then has different property names) or use profiles and two runs, but that's tedious. Maybe we should fix this issue ? Unfortunately, I don't have time to code on it, but maybe someone could pick up the ideas laid out in this issue ? |
Just for reference, at the end the "easiest" solution I could find was to use antrun plugin for filtering the files. (Refactoring the whole project as a multi-module pom would have been quite complex) I added this plugin here:
I used the ant delimiter (@) in the Dockerfile:
And changed the image builds to point to the generated Dockerfiles:
|
@rohanKanojia @rhuss Any updates on this PR? I would really like to use this feature in my project. |
@JollyGoodHolly : hmm, let me revisit this whenever I can. |
Ping @rhuss in case he hasn't seen the reworked PR. |
Thanks for merging this. Is a new version release planned soon? |
Yes. I just want to integrate some of the remaining PRs, and then do a release right after this. |
When will this fix be available? |
@gurpiarbassi : Is this issue still reproducible in v0.38.0? |
Description
Trying to build a
Dockerfile
like the following fails when using the maven plugin, but is supported and succeeds when building from the command line.https://docs.docker.com/engine/reference/builder/#from
VS when run from the command line
Info
mvn -v
) :docker version
):The text was updated successfully, but these errors were encountered: