Category: WordPress

Batch run WP-CLI on Docker containers


list themes:

docker ps -f "ancestor=wordpress" --format "{{.Names}}" | xargs -I % \
  sh -c 'echo "\n\n%\n"; docker exec % wp --allow-root theme list'

update all themes:

docker ps -f "ancestor=wordpress" --format "{{.Names}}" | xargs -I % \
  sh -c 'echo "\n\n%\n"; docker exec % wp --allow-root theme update --all'

WordPress in Docker

GS Cloud runs this blog and many others as Docker containers.

Repository: docker_wordpress Demo: wordpress-in-docker.mxd.cz

WordPress in Docker consists of three service containers: WordPress, MariaDB and phpMyAdmin.

WordPress and MariaDB use local volumes to store persistent data. PMA and WordPress are enhanced with uploads.ini injection to modify the default PHP settings. Both WordPress and PMA containers connect directly to the MariaDB container. There’s also a WP-CLI phar available as “wp” in the WordPress container.

WordPress output is then passed through Apache 2.4 proxy with Cloudflare certificates (not part of the demo).