I have a dockerfile that declares some environment variables that are being used later in the entrypoint, but the entrypoint never picks up the values for those variables. I tried the shell form but looks like its not doing anything. Here is my sample dockerfile :-
FROM java:8
ENV JAVA_OPTS="
RUN apt-get -y install ca-certificates curl
RUN mkdir /app
RUN mkdir /docker
CMD ["java", "-version"]
ADD /target/app.jar /app/app.jar
ENV spring.profiles.active dev
ENV encryptor.password xyz
COPY entrypoint.sh /docker/entrypoint.sh
RUN ["chmod", "+x", "/docker/entrypoint.sh"]
EXPOSE 8080
ENTRYPOINT ["/bin/bash", "-c", "/docker/entrypoint.sh"]
CMD ""
My entrypoint.sh is very simple and uses these ENV variables :-
#!/bin/bash
java -Djava.security.egd="file:/dev/./urandom" -Dencryptor.password=$encryptor.password -Dspring.profiles.active=$spring.profiles.active -jar /app/app.jar
How should i make my ENTRYPOINT to be able to access those ENV variables declared earlier in the Dockerfile so that its able to assign appropriate values to the arguments passed in. Went through several posts and stuffs on the internet and tried lot of ways to get this work, but didn't seem to work a single time.