I use dockerfiles to create a container. I know docker, but my bash understanding is very very limited. I know this question is probably a duplicate, but I don't understand what to search for.
Issue
The step RUN export A_NUM=$(echo ${A_VERSION} | head -c 3)
does not work. Even though in bash
it perfectly works. I tried:
- setting
ENV A_VERSION=$A_VERSION
- replicating my issue in bash (by going into the built container)
Any export
statement in the dockerfile seems to be futile - can anybody explain this?
Setting
I have app_A and app_B. When I configure app_B I need to take the chosen version of app_A into account. A simplified dockerfile looks like this:
FROM openjdk:8-jdk-slim
ARG A_VERSION=3.1.3
# RUN install app_A with A_VERSION
# RUN install app_B
WORKDIR /HOME/A_USER
USER A_USER
# RUN set some environment variables for app_A
RUN export A_NUM=$(echo ${A_VERSION} | head -c 3)
RUN echo $A_NUM
RUN if awk 'BEGIN {exit !('$A_NUM' >= '3.2')}'; then export path_A="/opt/Name_A"; else export path_A="/usr/local/Name_A"; fi
# RUN Use B_VERSION to set some environment variables for app_B