This project provides a Docker Compose setup for running WordPress with MySQL, plus an automated WP-CLI bootstrap script to install and configure the site.
.
├── bootstrap/ # Initialization scripts
│ └── wp-init.sh # WP-CLI bootstrap script
├── docker-compose.yml # Docker Compose configuration
├── mount/ # Mounted local resources
│ ├── plugins/ # Plugin ZIPs to be auto-installed
│ ├── themes/ # Theme ZIPs to be auto-installed
│ ├── uploads.ini # PHP upload config override
│ └── activationkey.php # Example custom file
├── volumes/ # WordPress & MySQL data (git-ignored)
└── restart.sh # Helper script to restart containers
docker compose up -dThis will start:
- WordPress 6.8.2-php8.4-apache
- MySQL 9.4.0
- WP-CLI 2.6.0 one-time container (
wpcli) which runsbootstrap/wp-init.sh.
Use the helper script:
./restart.shThis clears old containers, restarts services, and re-runs the wpcli init.
- Place plugin
.zipfiles in./mount/plugins/ - Place theme
.zipfiles in./mount/themes/
On initialization, the wpcli container will:
- Install WordPress core (if not installed)
- Set site title, admin user, permalink, timezone, etc.
- Install plugins defined in
.env(WP_PLUGINS) - Install all ZIPs found in
./mount/plugins/ - Install all ZIPs found in
./mount/themes/
Site configuration is controlled via .env. Example:
SITE_URL=http://localhost:8080
SITE_TITLE=My Awesome Site
WP_ADMIN_USER=admin
WP_ADMIN_PASSWORD=changeme123
WP_ADMIN_EMAIL=admin@example.com
WP_PLUGINS=classic-editor
WP_LOCALE=zh_CN
WP_PERMALINK=/%postname%/
WP_TIMEZONE=Asia/Shanghai- If you see
Could not create directoryerrors, ensure the mountedvolumes/directory is writable. - To verify mounted ZIPs inside
wpcli:docker compose exec wpcli ls -l /wp-plugins docker compose exec wpcli ls -l /wp-themes
- Data is persisted in
./volumes/wordpressand./volumes/database. - To reset WordPress core files without touching DB:
rm -rf ./volumes/wordpress/* docker compose up -d wordpress restart.shis tailored to yourdockcomp.shmanagement script — adjust if needed.