I have a wordpress container which gets generated by a docker-compose file. Wordpress container contains .htaccess
file by default. I want to edit that such that that the edit is performed only once when container is created.
For now I can think of two possible solutions for this problem:
We can use a static .htaccess
file and mount that as a volume at the place where original .htaccess
is copied, i.e, at /var/html/www
inside container. From updates to this answer, I have verified that this .htaccess
file will not get overwritten by default docker-entrypoint.sh
.
We can use the docker-entrypoint.sh from wordpress docker at github and modify the part which creates the .htaccess
file. This will keep the default behavior of entrypoint and .htaccess
file will also be modified.
Update: Answer given by @Nazar is also correct. Having a closer look at default docker-entrypoint.sh in wordpress image, I found that there is a condition at line 35, which checks if .htaccess
file already exists and creates a new file only if file does not exist. So, if I create my own file using RUN
, it will not be overwritten.
The easiest way is to build your own image based on wordpress:with-netcat, with all required preparations:
FROM wordpress:with-netcat
RUN /. EDIT YOUR .htaccess file here ./
ENTRYPOINT ...
CMD ...
And to use this image instead of the original one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With