WP Staging CLI can create and manage Docker-based WordPress environments for local development and testing. This guide covers how to add, list, delete, and manage WordPress sites.
What You’ll Get
Each Docker site includes:
- PHP-FPM with your chosen PHP version
- Nginx web server with HTTPS
- MariaDB database
- Mailpit for email testing
- Automatic SSL certificates via mkcert
- Hosts file configuration for local domains
Prerequisites
- Docker 20.10.0 or later
- Docker Compose 2.19.0 or later
- 2 CPU cores and 4 GB RAM minimum
Add a New Site
Create a new WordPress site with a custom local domain:
wpstaging add https://mysite.localOr without the protocol:
wpstaging add mysite.localAfter the site is created, you can access it at https://mysite.local.
Add a Site from Backup
Create a new site and restore from a WP Staging backup in one step:
wpstaging add mysite.local --from=backup.wpstgOr from a remote URL:
wpstaging add mysite.local --from=https://example.com/backup.wpstgThis is the recommended way to create a local copy of your production site. It handles everything: Docker setup, backup extraction, database import, and URL replacement.
Customize Site Configuration
PHP Version
Specify the PHP version (default is 8.1):
wpstaging add mysite.local --php=8.2Available PHP versions depend on the Docker images supported.
WordPress Version
Install a specific WordPress version (default is latest):
wpstaging add mysite.local --wp=6.4.2Custom Ports
Change the default ports if they conflict with other services:
wpstaging add mysite.local \
--http-port=8080 \
--https-port=8443 \
--db-port=3307Container IP Address
By default, sites use IP addresses in the 127.3.2.x range. You can specify a custom IP:
wpstaging add mysite.local --container-ip=127.0.0.1Environment Path
Change where Docker environments are stored (default: ~/wpstaging):
wpstaging add mysite.local --env-path=/custom/pathAll Add Command Flags
| Flag | Default | Description |
|---|---|---|
--php | 8.1 | PHP version |
--wp | latest | WordPress version |
--from | – | Backup file path or URL to restore |
--env-path | ~/wpstaging | Path to store Docker environments |
--container-ip | 127.3.2.1 | Container IP address |
--http-port | 80 | Nginx HTTP port |
--https-port | 443 | Nginx HTTPS port |
--db-port | 3306 | MariaDB port |
--db-root | 123456 | MariaDB root password |
--mailpit-http-port | 8025 | Mailpit web interface port |
--disable-mailpit | false | Disable Mailpit container |
WordPress Configuration Flags
| Flag | Default | Description |
|---|---|---|
--db-name | auto | WordPress database name |
--db-user | auto | WordPress database user |
--db-pass | auto | WordPress database password |
--db-prefix | wp_ | WordPress table prefix |
--db-host | localhost | WordPress database hostname |
--db-ssl | false | Enable SSL for WordPress database connection |
--admin-user | admin | WordPress admin username |
--admin-pass | admin | WordPress admin password |
--admin-email | admin@dev.null | WordPress admin email |
--secure-credentials | false | Generate random secure credentials |
--multisite | false | Enable WordPress Multisite |
List Sites
View all WordPress sites in your Docker environment:
wpstaging listExample output:
HOSTNAME STATUS PHP IP
mysite.local running 8.1 127.3.2.1
dev.local stopped 8.2 127.3.2.2
test.local running 8.0 127.3.2.3View Details for Specific Sites
Get detailed information about one or more sites:
wpstaging list mysite.localOr multiple sites:
wpstaging list site1.local site2.localDelete Sites
Delete a specific site:
wpstaging del mysite.localDelete multiple sites:
wpstaging del site1.local site2.localDelete all sites (with confirmation):
wpstaging delWarning: Deleting a site removes all its files, database, and configuration. This cannot be undone.
Enable/Disable Sites
Disable a site without deleting it:
wpstaging disable mysite.localRe-enable a disabled site:
wpstaging enable mysite.localDisabled sites keep their data but their containers are not started.
Reset a Site
Reset a site to a fresh WordPress installation:
wpstaging reset mysite.localThis removes all WordPress content and reinstalls WordPress while keeping the Docker configuration intact.
Reset with Different WordPress Version
Specify a different WordPress version during reset:
wpstaging reset mysite.local --wp=6.5Reset and Restore from Backup
Reset the site and restore from a WP Staging backup in one step:
wpstaging reset mysite.local --from=backup.wpstg
wpstaging reset mysite.local --from=https://example.com/backup.wpstgSecure Credentials
For better security, especially in shared environments, use random credentials:
wpstaging add mysite.local --secure-credentialsThis generates random passwords for:
- MariaDB root user
- WordPress database user
- WordPress admin user
The generated credentials are displayed after site creation.
WordPress Multisite
Create a WordPress Multisite installation:
wpstaging add mynetwork.local --multisitemacOS Notes
macOS Users: Automatic IP alias binding is enabled by default for seamless multi-site setups using loopback IP range 127.3.2.1 – 127.3.2.254. This requires sudo and you’ll be prompted for your password.
Tip: Set up passwordless sudo for wpstaging to avoid repeated password prompts. See the FAQ for instructions.
Next Steps
- Control Docker Containers – Start, stop, and manage containers
- Docker Configuration – Advanced configuration options
- Create a Local Copy of WordPress Site – Complete tutorial