Control Docker Containers

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 start

Start containers for a specific site:

wpstaging start mysite.local

Alias: You can also use wpstaging up as an alternative to start.

Stop Containers

Stop containers for all sites:

wpstaging stop

Stop containers for a specific site:

wpstaging stop mysite.local

Alias: You can also use wpstaging down as an alternative to stop.

Restart Containers

Restart containers for all sites:

wpstaging restart

Restart containers for a specific site:

wpstaging restart mysite.local

Use restart when you’ve made configuration changes or if a site is not responding.

Check Container Status

View the status of all sites:

wpstaging status

Example 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: Up

Check status for specific sites:

wpstaging status mysite.local

Or multiple sites:

wpstaging status site1.local site2.local

Access PHP Shell

Open an interactive shell in the PHP container (as the web server user):

wpstaging shell mysite.local

Open a shell as root:

wpstaging shell mysite.local root

Once 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$ exit

Access Database Shell

Open an interactive shell in the MariaDB container:

wpstaging shell-db mysite.local

Open as root:

wpstaging shell-db mysite.local root

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

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

CommandAliasDescription
start [hostname]upStart containers
stop [hostname]downStop containers
restart [hostname]Restart containers
status [hostname...]Show container status
shell <hostname> [root]PHP container shell
shell-db <hostname> [root]Database container shell
removeRemove 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

Updated on January 27, 2026