WP Staging CLI provides commands to control Docker containers for your WordPress sites. This guide covers starting, stopping, restarting containers, checking status, and accessing shells.
Start Containers
Start containers for all sites:
wpstaging startStart containers for a specific site:
wpstaging start mysite.localAlias: You can also use wpstaging up as an alternative to start.
Stop Containers
Stop containers for all sites:
wpstaging stopStop containers for a specific site:
wpstaging stop mysite.localAlias: You can also use wpstaging down as an alternative to stop.
Restart Containers
Restart containers for all sites:
wpstaging restartRestart containers for a specific site:
wpstaging restart mysite.localUse restart when you’ve made configuration changes or if a site is not responding.
Check Container Status
View the status of all sites:
wpstaging statusExample output:
HOSTNAME STATUS CONTAINERS
mysite.local running php: Up, nginx: Up, mariadb: Up, mailpit: Up
dev.local stopped php: -, nginx: -, mariadb: -, mailpit: -
test.local running php: Up, nginx: Up, mariadb: Up, mailpit: UpCheck status for specific sites:
wpstaging status mysite.localOr multiple sites:
wpstaging status site1.local site2.localAccess PHP Shell
Open an interactive shell in the PHP container (as the web server user):
wpstaging shell mysite.localOpen a shell as root:
wpstaging shell mysite.local rootOnce inside the shell, you have access to:
- WordPress files in
/var/www/html - WP-CLI for WordPress management
- PHP and Composer
Example shell session:
$ wpstaging shell mysite.local
www-data@php:/var/www/html$ wp plugin list
+----------------+----------+--------+---------+
| name | status | update | version |
+----------------+----------+--------+---------+
| akismet | inactive | none | 5.3 |
| hello | inactive | none | 1.7.2 |
+----------------+----------+--------+---------+
www-data@php:/var/www/html$ exitAccess Database Shell
Open an interactive shell in the MariaDB container:
wpstaging shell-db mysite.localOpen as root:
wpstaging shell-db mysite.local rootThis gives you direct access to the MySQL/MariaDB command line for database management.
Remove All Docker Data
Stop all containers and remove all Docker data (volumes, configurations, etc.):
wpstaging removeWarning: This command removes everything – all sites, databases, uploaded files, and configurations. This action cannot be undone. You’ll be prompted for confirmation before proceeding.
Use this command when you want to completely clean up your Docker environment or before uninstalling WP Staging CLI.
Environment Path Flag
All container commands support the --env-path flag to specify a custom Docker environment location:
wpstaging start --env-path=/custom/path
wpstaging stop --env-path=/custom/path
wpstaging status --env-path=/custom/path
Default: ~/wpstaging
Command Summary
| Command | Alias | Description |
|---|---|---|
start [hostname] | up | Start containers |
stop [hostname] | down | Stop containers |
restart [hostname] | – | Restart containers |
status [hostname...] | – | Show container status |
shell <hostname> [root] | – | PHP container shell |
shell-db <hostname> [root] | – | Database container shell |
remove | – | Remove all Docker data |
Troubleshooting
Containers Won’t Start
- Check if Docker is running:
docker info - Verify no port conflicts:
lsof -i :80(or the port in use) - Check Docker logs:
docker logs <container-name> - Ensure sufficient disk space and memory
Site Not Accessible
- Verify containers are running:
wpstaging status mysite.local - Check hosts file entry:
cat /etc/hosts | grep mysite.local - Update hosts file:
wpstaging update-hosts-file - Try restarting:
wpstaging restart mysite.local
Shell Access Denied
- Ensure the site containers are running
- Try accessing as root:
wpstaging shell mysite.local root
Next Steps
- Manage Docker WordPress Sites – Add, delete, and configure sites
- Docker Configuration – Advanced configuration
- Cleanup and Maintenance – Clean up resources