Skip to content

ENV declarations don't inherit values if declared on same line #10391

Closed

Description

@n0coast

Attempting to declare multiple variables that reference previously declared variables on one line doesn't seem to work, for example this declaration will create variables that contain strings instead of expanded variable definitions:

ENV JAVA_VERSION=jdk1.7.0_75 \
    JAVA_HOME=/usr/$JAVA_VERSION \ 
    JAVA_BIN=$JAVA_HOME/bin \
    JRE_HOME=$JAVA_HOME/jre

After building a container with the above ENV declarations the environment will contain:

JAVA_VERSION=jdk1.7.0_75
JAVA_HOME='/usr/$JAVA_VERSION'
JAVA_BIN='$JAVA_HOME/bin'
JRE_HOME='$JAVA_HOME/jre'

Where I would expect those variables to have been expanded.

On the other hand creating variables using multiple ENV statements will work and variables will contain the expanded variables:

ENV JAVA_VERSION jdk1.7.0_75
ENV JAVA_HOME /usr/$JAVA_VERSION
ENV JAVA_BIN $JAVA_HOME/bin
ENV JRE_HOME $JAVA_HOME/jre

After building a container with the above ENV declarations the environment will contain:

JAVA_VERSION=jdk1.7.0_75
JAVA_HOME=/usr/jdk1.7.0_75
JAVA_BIN=/usr/jdk1.7.0_75/bin
JRE_HOME=/usr/jdk1.7.0_75/jre

It wasn't apparent in the documentation that this should or should not work, and the second method causes 3 extra intermediate containers to be built. As the statements are very similar it would be nice to have then behave similarly, or the difference be documented.

Activity

  1. duglin commented on Jan 29, 2015

    @duglin
    Contributor

    This is a cool one :-)

  2. duglin commented on Jan 29, 2015

    @duglin
    Contributor

    Opened PR #10431 for this.

  3. added
    kind/enhancement
    kind/feature
    and removed
    kind/enhancement
    on Feb 28, 2015
  4. jessfraz commented on Mar 2, 2015

    @jessfraz
    Contributor

    closing as dup of #8667

  5. added a commit that references this issue on Mar 23, 2015
    7758553
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

    kind/feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions