In any project there are steps necessary to build an environment. Many times these steps can be repetitive. Using Docker Containers is a great way to minimize repetition. And Docker Compose can help make things even better.
Below is an explanation to a boilerplate project I created using Docker Containers for local WordPress development. You can download this boilerplate on my GitHub account.
After downloading the project to your local machine, replace
mydomainname.com in the
.env file with any value of your choice. The value you set will be used to:
- Create a database in the mariadb Container.
- Configure the WordPress Container to use the new database.
- Name Docker Containers for easy identification.
NOTE: The MariaDB Container is simply named mariadb.
Both the WordPress and MariaDB Docker Containers make use of variables. Below are their default values.
- MYSQL_DATABASE=mydomainname.com - MYSQL_ROOT_PASSWORD=root_password - MYSQL_USER=wordpress - MYSQL_PASSWORD=wordpress - WORDPRESS_DEBUG=1
- WORDPRESS_DB_NAME=mydomainname.com - WORDPRESS_DB_HOST=db:3306 - WORDPRESS_DB_USER=wordpress - WORDPRESS_DB_PASSWORD=wordpress
Next I want WP CLI to automatically complete the initial WordPress setup. It should also automatically install and activate any plugins needed.