Skip to content

Fix ARG referencing another ARG in FROM statement #1800

Closed

Description

@kevinleturc

Description

Building from a Dockerfile like the one below:

ARG IMAGE_NAME=alpine
ARG IMAGE_TAG=latest
ARG FULL_IMAGE=${IMAGE_NAME}:${IMAGE_TAG}
FROM ${FULL_IMAGE}

results in the error below:

Caused by: java.lang.IllegalArgumentException: Illegal group reference
    at java.util.regex.Matcher.appendExpandedReplacement (Matcher.java:1113)
    at java.util.regex.Matcher.appendReplacement (Matcher.java:1043)
    at java.util.regex.Matcher.replaceFirst (Matcher.java:1446)
    at java.lang.String.replaceFirst (String.java:3025)
    at io.fabric8.maven.docker.util.DockerFileUtil.resolveImageTagFromArgs (DockerFileUtil.java:189)
    at io.fabric8.maven.docker.util.DockerFileUtil.extractBaseImages (DockerFileUtil.java:70)

This is because DockerFileUtil.resolveImageTagFromArgs doesn't recursively resolve the args, and the curly brackets of the inner arg breaks the Pattern replacement.

Info

  • docker-maven-plugin version: 0.44.0
  • Maven version (mvn -v): 3.9.8
  • Docker version: 27.0.3

Activity

  1. rohanKanojia commented on Jul 28, 2024

    @rohanKanojia
    Member

    @kevinleturc : I have released 0.45.0 . Could you please check if everything is working as expected in your project and provide feedback?

  2. kevinleturc commented on Jul 30, 2024

    @kevinleturc
    ContributorAuthor

    @kevinleturc : I have released 0.45.0 . Could you please check if everything is working as expected in your project and provide feedback?

    I have checked the fix in our project and everything is working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions