Warm tip: This article is reproduced from stackoverflow.com, please click
docker docker-compose wordpress wp-cli

WordPress Plugins and Themes not working with WP-CLI and Docker Compose

发布于 2020-04-07 10:20:57

I've connected my wpcli container to my wp container, but only some functionality works. I can edit posts, menus, etc., but themes and plugins are not working. If I run docker-compose run --rm wpcli wp theme list or docker-compose run --rm wpcli wp plugin list I get an empty table. Some similar question answers have recommended setting attributes -u 33 -e HOME=/tmp or setting user: xfs in the docker-compose file, but it doesn't seem to help. Any direction would be appreciated.

Here's my docker-compose.yml file:

version: "3.7"

services:

  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: password
    ports:
      - "3306:3306"
    volumes:
      - db_data:/var/lib/mysql
    networks:
      - back

  wp:
    image: wordpress:latest
    depends_on:
      - db
    restart: always
    ports:
      - "80:80"
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_PASSWORD: password
      WORDPRESS_DEBUG: 1
    volumes:
      - ./wp-content/:/var/www/html/wp-content/
      - wp_data:/var/www/html/
    networks:
      - back

  wpcli:
    image: wordpress:cli
    volumes:
      - wp_data:/var/www/html
    networks:
      - back

networks:
  back:
volumes:
  db_data:
  wp_data:
Questioner
Rice_Crisp
Viewed
140
Rice_Crisp 2020-02-01 05:51

Figured it out. Added ./wp-content/:/var/www/html/wp-content/ to the volumes. Docker defaults any named volumes to root, so by binding it dropped the root owner.