Wordpress¶
Overview¶
I am using a devcontainer to work on a Wordpress site locally. My current setup runs these services:
- wordpress
- An Apache server, as well as a devcontainer that inludes WP-CLI, with a local source directory added as bind mount.
- db
- A MySQL server, with its database stored on a Docker volume.
- pma
- A PhpMyAdmin server, to manage the database(s).
Configuration¶
Directory structure¶
Note
I have seen different hosting providers offer ways to deploy a git repository to a website. However, this typically "disconnects" the repository from the files themselves.
I prefer a scenario where my hosted Wordpress site automatically installs security updates. With ssh access, I can then commit those changes to the repository.
Docker configuration¶
Docker Desktop reads the .env
file when starting up services.
These variables can then be passed to a container.
Warning
When using Docker Desktop on Linux, directories and files mounted into a container are owned by user root
.
Docker Desktop maps between the local user on the host, and root
in the container.
However, the Apache server in the container runs as user www-data
. It is therefore not possible to install or upgrade Wordpress or its plugins from the Wordpress admin interface.
Therefore, VS Code accesses the devcontainer as root
too.
The WP-CLI
utility makes it possible to do code maintenance on Wordpress and plugins. This requires the --allow-root
option.
wp --allow-root plugin install hello-dolly