FROM php:5.6-apache
WORKDIR /var/www/html/
# ENV VARIABLES
ENV INI_FOLDER /usr/local/etc/php
ENV WWW_FOLDER /var/www
# ADD THE ENV CONFIGURATOR AND SET PERMISSIONS
ADD env.sh $WWW_FOLDER/
RUN chmod +x $WWW_FOLDER/env.sh
RUN /var/www/env.sh
The problems is that in env.sh I don’t have access to the variables set on the docker-compose (app.env, mysql.env). Is there any workaround to fix this?
the RUN steps are used to build the image. The docker-compose uses later that immutable image. So it’s just normal that the env in docker-compose has no effect to the immutable image.
If you want to react based on environment you can override your CMD. There you have full access to env also added later in compose.
So your recommendation is to use CMD [’/path/to/my/script.sh’] to override the default CMD and there I can use the ENV vars. Correct? If yes, Thank you.