Reputation: 51
Is there any chance to pass variables from docker-compose into apache.conf
file?
I have Dockerfile with variables
ENV APACHE_SERVER_NAME localhost
ENV APACHE_DOCUMENT_ROOT /var/www/html
I have apache.conf which I copy into /etc/apache2/sites-available/ while building image
ServerName ${APACHE_SERVER_NAME}
DocumentRoot ${APACHE_DOCUMENT_ROOT}
I have docker-compose.yml
environment:
- APACHE_SERVER_NAME=cms
- APACHE_DOCUMENT_ROOT=/var/www/html/public
When I run docker-compose
, nothing happened and apache.conf
in container is unchanged.
Am I completely wrong and is this imposible or am I missing any step or point?
Thank you
Upvotes: 1
Views: 1610
Reputation: 3691
Let me explain some little differences among ways to pass environment variables:
Environment variables for building time and for entrypoint in running time
docker run -e VAR=value...
The same than before but for cli.Environment variables only for building time
Environment variables accesibled for every container and builds
.env
file defined in your working dir where executes docker run
or docker-compose
..env
file.As you're trying to define variables for apache conf file, maybe you should try to use apache as entrypoint, or just define them in .env
file.
Upvotes: 1