Skip to content

Fix ARG referencing another ARG in FROM statement #1800

@kevinleturc

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

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