<p>I have a magento deployment on nginx which uses a persistent volume and a persistent volume claim. Everything works fine, but I am struggeling with one problem. I am using an initContainer to install magento via cli (which works fine) but as soon my POD starts and mounts the PVC to the <code>/var/www/html</code> (my webroot) the data previously (in the initContainer) installed data is lost (or better replaced by the new mount). My workaround was to install magento into <code>/tmp/magento</code> (in the initContainer) and as soon the "real" POD is up, the data from <code>/tmp/magento</code> is copied to <code>/var/www/html</code>. As you can imagine this takes a while and is kind of a permission hell, but it works.</p>

<p>Is there any way, that I can install my app directly in my target directory, without "overmapping" my files? I have to use an PV/PVC because I am mounting the POD directory via NFS and also I don't want to loose my files.</p>

<p>Update: The Magento deployment is inside a docker image and is installed during the docker build. So if I install the data into the target location, the kubernetes mount replaces the data with an empty mount. That's the main reason for the workaround. The goal is to have the whole installation inside the image.</p>

Jake
<p>If Magento is already installed inside the imaged and located by some path (say <code>/tmp/magento</code>) but you want it to be accessible by path <code>/var/www/html/magento</code>, why don't you just create a symlink pointing to the existing location?</p>

<p>So your Magento will be installed during the image build process and in the entrypoint an additional command</p>

<pre><code>ln -s /tmp/magento /var/www/html/magento
</code></pre>

<p>will be run before the Nginx server starts itself. No need for intiContainers.</p>
