This is a Docker based local development environment for WordPress.
This project is based on WP Local Docker by 10up and docker-compose.
By default, the following containers are started: PHP-FPM, MariaDB, Apache, and Redis.
The /wordpress
directory is the web root which is mapped to the Apache and PHP containers.
Custom php and apache images are used for this environment.
git clone https://github.com/ChrisWiegman/docker-wordpress <my-project-name>
cd <my-project-name>
./develop up
- Run setup to download WordPress and create a
wp-config.php
file.- On Linux / Unix / OSX, run
.bin/setup
.
- On Linux / Unix / OSX, run
- Navigate to
http://localhost
in a browser to access your WordPress site.- If you want to use a domain other than
http://localhost
, you'll need to add an entry to your hosts file. Ex:127.0.0.1 docker.dev
- If you want to use a domain other than
Default MySQL connection information (from within PHP-FPM container):
Database: wordpress
Username: wordpress
Password: password
Host: mysql
Default WordPress site information:
Username: admin
Password: password
Adding a docker-compose.override.yml
file alongside the docker-compose.yml
file, with contents similar to
the following, allows you to change the domain associated with the cluster while retaining the ability to pull in changes from the repo.
version: '3'
services:
phpfpm:
extra_hosts:
- "dashboard.dev:172.18.0.1"
elasticsearch:
environment:
ES_JAVA_OPTS: "-Xms2g -Xmx2g"
There is also a script in the /bin
directory that will allow you to execute WP CLI from the project directory directly: ./bin/wp plugin install
.
Alternatively, there is a script in the /bin
directory that allows you to SSH in to the environment from the project directory directly: ./bin/shell
.
MailCatcher runs a simple local SMTP server which catches any message sent to it, and displays it in it's built-in web interface. All emails sent by WordPress will be intercepted by MailCatcher. To view emails in the MailCatcher web interface, navigate to http://localhost:1080
in your web browser of choice.
PHP versions from 5.6-7.2 are available. While the stack defaults to PHP 7.2 all you need to do is change the image: chriswiegman/php:7.2
line from 7.2 to the version you want to use (5.6, 7.0, 7.1 or 7.2) and restart your stack.
This project is based off of similar work by 10up