I have a Wordpress container that I would like to copy local folders (with files) to at startup
I have local files in folders:
/html/wp-content/plugins
/html/wp-content/themes
/html/wp-content/uploads
I have a Dockerfile with:
FROM wordpress
COPY ./html/wp-content/plugins/ /var/www/html/wp-content/plugins
COPY ./html/wp-content/themes/ /var/www/html/wp-content/themes
COPY ./html/wp-content/uploads/ /var/www/html/wp-content/uploads
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["apache2-foreground"]
Although the COPY is succeeding (the build passes), the files are not showing up in these destination folders.
If I change the destination folders to be on any path before /html, eg if I put the destination to be /var or /var/www, then the files copy and I can see them in the container.
I checked out this old post here, which mentions that the /html folder is actually mounted as a volume at startup, and so I need to copy the files into this folder first
/usr/src/wordpress/wp-content
and then at startup these folders will be automatically copied across to /var/www/html/wp-content/. (This would explain why copying directly does not seem to work)
I tried that too, and while my local folders are indeed copied into these folders (I can see them in the container), they are then not copied across to /var/www/html/content at startup!
- Is it possible to copy the local files directly into the /var/www/html folders via the dockerfile?
- If not, how can I ensure that if copying to /usr/src/wordpress/wp-content, the folders will be copied across to /var/www/html/wp-content/ at startup?
(Some posts I've looked through that don't work, as this seems to be particular to Wordpress, and not Dockerfile COPY on its own:)
Dockerfile copy keep subdirectory structure Docker is not copying subdirectory into Container How to copy folders to docker image from Dockerfile? https://www.serverlab.ca/tutorials/containers/docker/how-to-host-your-wordpress-site-with-docker/ Wordpress docker copy theme into exposed folder