4

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!

  1. Is it possible to copy the local files directly into the /var/www/html folders via the dockerfile?
  2. 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

leo_cape
  • 117
  • 1
  • 12
  • 1
    [Ronald Johnson](https://stackoverflow.com/users/7628376/ronald-johnson) posted an [Answer](https://stackoverflow.com/a/65235658/12695027) saying "..a misplaced or not placed '/' at the end of a path in apache2.conf or other config file" – Scratte Dec 10 '20 at 21:07
  • 1
    Did you find a solution regarding this and can share? Having same issue myself! – Flamur Mavraj Jun 27 '21 at 02:27
  • @FlamurMavraj in the end I changed direction and used a mounted volume instead, which helped slightly with the deployment pipeline. But still unable to find a silver bullet pipeline for wordpress - so I still have to make some changes to production on production itself which isnt great. – leo_cape Jul 20 '21 at 12:52
  • @Scratte the answer must have been deleted, but from what you're saying I dont think that was the problem.. – leo_cape Jul 20 '21 at 12:53
  • @leo_cape Yes, it was deleted. I came across it when reviewing. I didn't know if it would be useful or not, so I put the content in a comment. I can remove the comment, if you like. – Scratte Jul 20 '21 at 13:22

0 Answers0