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:
Prerequisites
Add a New Site
Create a new WordPress site with a custom local domain:
Or without the protocol:
Need a WordPress Multisite?
After the site is created, you can access it at https://mysite.local.
Add a Site from an existing backup file
Create a new site and restore from a WP Staging backup file in one step:
Or from a remote URL:
WordPress Multisite:
This 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):
Available PHP versions depend on the Docker images supported.
WordPress Version
Install a specific WordPress version (default is latest):
Custom Ports
Change the default ports if they conflict with other services:
Container IP Address
By default, sites use IP addresses in the 127.3.2.x range. You can specify a custom IP:
Environment Path
Change where Docker environments are stored (default: ~/wpstaging):
All 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:
Example output:
View Details for Specific Sites
Get detailed information about one or more sites:
Or multiple sites:
Delete Sites
Delete a specific site:
Delete multiple sites:
Delete all sites (with confirmation):
Warning: Deleting a site removes all its files, database, and configuration. This cannot be undone.
Enable/Disable Sites
Disable a site without deleting it:
Re-enable a disabled site:
Disabled sites keep their data but their containers are not started.
Reset a Site
Reset a site to a fresh WordPress installation:
This 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:
Reset and Restore from Backup
Reset the site and restore from a WP Staging backup in one step:
Secure Credentials
For better security, especially in shared environments, use random credentials:
This generates random passwords for:
The generated credentials are displayed after site creation.
WordPress Multisite
Create a WordPress Multisite installation:
macOS 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.