Dots in ENV variable in dockerfile doesn't work

Viewed 1322

When I declare ENV variable with dots in name, they does not set properly. To framework that I am dockerizing requires this variable to be set:

  framework.config.location 

Dockerfile

ENV JAVA_HOME=/opt/java/jre1.8 \
framework.config.location=$HOME/framework/config 

RUN echo $framework.config.location && \
    cd $framework.config.location

.config.location

/bin/sh: 1: cd: can't cd to .config.location

1 Answers

I think framework.config.location (and in general a string containing dots) is not a valid identifier from the perspective of Unix shells like bash.

You can however use it in ENV section of you Dockerfile: the result is something like

env framework.config.location=$HOME/framework/config TheCommand

but you can't access the variable's value through $framework.config.location orf {$framework.config.location}. you can read it using value=$(env | grep 'framework.config.location' | cut -f 2 -d '=') and then use as $value...

Related