A Docker Compose development environment for WordPress plugin and theme development.
- WordPress with PHP 8.2
- MySQL 8 database
- Adminer for database management
- Fake SMTP server for email testing
- Debug logging enabled by default
- Increased upload limits (64MB)
- Docker
- Docker Compose
-
Copy the environment file:
cp .env.example .env
Update
.envchanging defaults. -
Start the containers:
docker compose up
-
Access WordPress at
http://wp-docker.localhost(or your configured host and port)
Configure the environment via .env:
| Variable | Default | Description |
|---|---|---|
WP_HOST |
wp-docker.localhost |
WordPress hostname |
WP_PORT |
80 |
WordPress port |
WP_DEBUG |
true |
Enable WordPress debug mode |
ADMINER_PORT |
8081 |
Adminer port |
SMTP_HTTP_PORT |
8082 |
Fake SMTP web interface port |
| Service | URL | Description |
|---|---|---|
| WordPress | http://${WP_HOST}:${WP_PORT} |
Main WordPress site |
| Adminer | http://localhost:${ADMINER_PORT} |
Database management UI |
| Fake SMTP | http://localhost:${SMTP_HTTP_PORT} |
View sent emails |
- Host:
db - Database:
exampledb - User:
exampleuser - Password:
examplepass
The wp-content/ directory is mounted to the host for development:
wp-content/
├── mu-plugins/ # Must-use plugins
├── plugins/ # Regular plugins
└── themes/ # Themes
The .gitignore is configured to ignore all files in wp-content/ except for:
wp-content/object-cache.phpwp-content/mu-plugins/autoload.php
To un-ignore a file inside a subdirectory, you must first un-ignore the parent directory, then re-ignore its contents, then un-ignore the specific file:
# Ignore everything in wp-content
wp-content/*
# Un-ignore a file directly in wp-content
!wp-content/object-cache.php
# Un-ignore a file in a subdirectory
!wp-content/mu-plugins/
wp-content/mu-plugins/*
!wp-content/mu-plugins/autoload.php