Manage Docker WordPress Sites

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.local

Or without the protocol:

wpstaging add mysite.local

After 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.wpstg

Or from a remote URL:

wpstaging add mysite.local --from=https://example.com/backup.wpstg

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):

wpstaging add mysite.local --php=8.2

Available 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.2

Custom Ports

Change the default ports if they conflict with other services:

wpstaging add mysite.local \
  --http-port=8080 \
  --https-port=8443 \
  --db-port=3307

Container 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.1

Environment Path

Change where Docker environments are stored (default: ~/wpstaging):

wpstaging add mysite.local --env-path=/custom/path

All Add Command Flags

FlagDefaultDescription
--php8.1PHP version
--wplatestWordPress version
--fromBackup file path or URL to restore
--env-path~/wpstagingPath to store Docker environments
--container-ip127.3.2.1Container IP address
--http-port80Nginx HTTP port
--https-port443Nginx HTTPS port
--db-port3306MariaDB port
--db-root123456MariaDB root password
--mailpit-http-port8025Mailpit web interface port
--disable-mailpitfalseDisable Mailpit container

WordPress Configuration Flags

FlagDefaultDescription
--db-nameautoWordPress database name
--db-userautoWordPress database user
--db-passautoWordPress database password
--db-prefixwp_WordPress table prefix
--db-hostlocalhostWordPress database hostname
--db-sslfalseEnable SSL for WordPress database connection
--admin-useradminWordPress admin username
--admin-passadminWordPress admin password
--admin-emailadmin@dev.nullWordPress admin email
--secure-credentialsfalseGenerate random secure credentials
--multisitefalseEnable WordPress Multisite

List Sites

View all WordPress sites in your Docker environment:

wpstaging list

Example 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.3

View Details for Specific Sites

Get detailed information about one or more sites:

wpstaging list mysite.local

Or multiple sites:

wpstaging list site1.local site2.local

Delete Sites

Delete a specific site:

wpstaging del mysite.local

Delete multiple sites:

wpstaging del site1.local site2.local

Delete all sites (with confirmation):

wpstaging del

Warning: 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.local

Re-enable a disabled site:

wpstaging enable mysite.local

Disabled sites keep their data but their containers are not started.

Reset a Site

Reset a site to a fresh WordPress installation:

wpstaging reset mysite.local

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:

wpstaging reset mysite.local --wp=6.5

Reset 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.wpstg

Secure Credentials

For better security, especially in shared environments, use random credentials:

wpstaging add mysite.local --secure-credentials

This 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 --multisite

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.

Next Steps

Updated on January 27, 2026