wordpress:cli<\/code> docker image.<\/p>\n\n\n\nHow does that work?<\/h3>\n\n\n\n As they say, an image says more then a thousands words. But, since text in images can’t be copied, I’ll copy\/paste the two services below:<\/p>\n\n\n\n
wp:\n container_name: ${NAME}-wp\n depends_on:\n - db\n image: wordpress:php8.0\n user: 1000:1000\n volumes:\n - .\/app\/www\/content\/plugins:\/var\/www\/html\/wp-content\/plugins\n - .\/app\/www\/content\/mu-plugins:\/var\/www\/html\/wp-content\/mu-plugins\n - .\/app\/www\/content\/themes:\/var\/www\/html\/wp-content\/themes\n - uploads:\/var\/www\/html\/wp-content\/uploads:rw\n - wordpress:\/var\/www\/html\n ports:\n - \"8000:80\"\n environment:\n WORDPRESS_DB_HOST: ${NAME}-db:3306\n WORDPRESS_DB_USER: ${DB_USER}\n WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}\n WORDPRESS_DB_NAME: ${DB_NAME}\n WORDPRESS_DEBUG: 1\n VIRTUAL_HOST: \"${SITE_DOMAIN}\" # Used for nginx-proxy\n VIRTUAL_PORT: 80 # Used for nginx-proxy\n LETSENCRYPT_HOST: \"${SITE_DOMAIN}\" # Used for nginx-proxy\n WORDPRESS_CONFIG_EXTRA: |\n \/* Multisite *\/\n define( 'MULTISITE', true );\n define( 'SUBDOMAIN_INSTALL', true );\n define( 'DOMAIN_CURRENT_SITE', 'sitec7' );\n define( 'PATH_CURRENT_SITE', '\/' );\n define( 'SITE_ID_CURRENT_SITE', 1 );\n define( 'BLOG_ID_CURRENT_SITE', 1 );\n expose:\n - \"80\"\n \n wpcli:\n container_name: ${NAME}-cli\n depends_on:\n - wp\n image: wordpress:cli\n user: 1000:1000\n command: tail -f \/dev\/null\n volumes:\n - wordpress:\/var\/www\/html\n environment:\n WORDPRESS_DB_HOST: ${NAME}-db:3306\n WORDPRESS_DB_USER: ${DB_USER}\n WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}\n WORDPRESS_DB_NAME: ${DB_NAME}\n profiles:\n - dev<\/code><\/pre>\n\n\n\nAs you see, both images use the same volume and environment setup. This allows you to run commands like:<\/p>\n\n\n\n
docker exec site-cli wp --info<\/code><\/pre>\n\n\n\nand<\/p>\n\n\n\n
docker exec site-cli wp search-replace \"test\" \"test1\" --dry-run<\/code><\/pre>\n\n\n\nWant to make it even easier? Set an alias for docker exec site-cli wp<\/code> so that you can run something like sitewp --info<\/code>. In my own development environment, my folders are named the same as my container. When you change directory, and the directory has an .env<\/code> file, an alias is set for wp<\/code> and links to the correct container.<\/p>\n\n\n\nHappy developing!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"For most of my WordPress projects I use my own Alcedo WordPress workflow. With some extra scripts, creating a new site is as easy as running ‘create site.c7’in the terminal. This sets up a full WordPress install with local domains and certificates. But, in this case i’m using a different setup in which I use […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[1],"tags":[],"acf":[],"yoast_head":"\n
Adding and using WP-CLI in a docker-compose setup - Marinus Klasen<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n \n \n\t \n\t \n\t \n