wordpressdockerwp-cliroots-sageacorn

wordpress docker: locate volume from different container using wpcli


I'm starting to learn WordPress sage with acorn to set up, and I'm using docker for this since I'm using a Windows machine.

I use some plugins like ACF:Composer using Acorn, When im on the point of adding options where he use this command wp acorn acf:options ThemeOptions im getting this error:

Warning: No WordPress installation found. If the command 'acorn acf:options ThemeOptions' is in a plugin or theme, pass --path=`path/to/wordpress`.
Error: 'acorn' is not a registered wp command. See 'wp help' for available commands.
Did you mean 'core'?

so I tried this flag `--path='path/to/wordpress`` so i use this command since im using wpcli for docker:

docker exec wpcli wp acorn acf:options ThemeOptions --path=`/var/www/html/`

but it gives me this error:

bash: /var/www/html/: No such file or directory
Error: The --path parameter cannot be empty when provided.

Here are my docker compose file and env:

Docker

version: '3.5'

services:
  wordpress:
    image: wordpress:6.4.3
    env_file:
      - .env
    environment:
      WORDPRESS_DB_HOST: ${WORDPRESS_DB_HOST}
      WORDPRESS_DB_USER: ${WORDPRESS_DB_USER}
      WORDPRESS_DB_PASSWORD: ${WORDPRESS_DB_PASSWORD}
      WORDPRESS_DB_NAME: ${WORDPRESS_DB_NAME}
      WORDPRESS_TABLE_PREFIX: ${WORDPRESS_TABLE_PREFIX}
      WORDPRESS_DEBUG: ${WORDPRESS_DEBUG}
      WORDPRESS_CONFIG_EXTRA: ${WORDPRESS_CONFIG_EXTRA}
    ports:
      - '80:80'
    volumes:
      - ./src/plugins:/var/www/html/wp-content/plugins
      - ./src/themes:/var/www/html/wp-content/themes


  db:
    build:
      context: .
      dockerfile: ./dockerfile/database/Dockerfile
    image: mariadb:11.2
    env_file:
      - .env
    environment:
      - MYSQL_ROOT_PASSWORD=${WORDPRESS_DB_PASSWORD}
      - MYSQL_DATABASE=${WORDPRESS_DB_NAME}
    volumes:
        - db_data:/var/lib/mysql
        - ./migrations/wordpress.sql:/docker-entrypoint-initdb.d/wordpress.sql

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    env_file:
      - .env
    links:
      - db
    environment:
      PMA_HOST: ${WORDPRESS_DB_HOST}
      PMA_USER: ${WORDPRESS_DB_USER}
      PMA_PASSWORD: ${WORDPRESS_DB_PASSWORD}
      PMA_PORT: 3306
    restart: always
    ports:
      - '8081:80'
  
  wpcli:
    image: wordpress:cli-2.9-php8.3
    env_file:
      - .env
    volumes:
      - wordpress:/var/www/html
      - ./migrations:/var/www/html/migrations
    environment:
      WORDPRESS_DB_HOST: ${WORDPRESS_DB_HOST}
      WORDPRESS_DB_USER: ${WORDPRESS_DB_USER}
      WORDPRESS_DB_PASSWORD: ${WORDPRESS_DB_PASSWORD}
      WORDPRESS_DB_NAME: ${WORDPRESS_DB_NAME}
    container_name: wpcli
    depends_on:
      - db
      - wordpress
    user: 1000:1000
    command: tail -f /dev/null

volumes:
  db_data:
  wordpress:

ENV

WORDPRESS_DB_HOST=db
WORDPRESS_DB_USER=root
WORDPRESS_DB_PASSWORD=root
WORDPRESS_DB_NAME=wordpress
WORDPRESS_TABLE_PREFIX=wp_
WORDPRESS_DEBUG=1
WORDPRESS_CONFIG_EXTRA=''

as you can see in my docker file in my wpcli service I mounted the volume of my wordpress service but when I check the docker desktop file explorer for wpcli container , I cant find my wordpress file: Docker Desktop file exploere

and here is my wordpress container: Wordpress Container

Thank you in advance!


Solution

  • I had trouble running this configuration without database dependency on wordpress service:

    depends_on:
        - db
    

    but I think the main problem is that this service doesn't have wordpress volume mounted to it:

    volumes:
        - wordpress:/var/www/html
        - ./src/plugins:/var/www/html/wp-content/plugins
        - ./src/themes:/var/www/html/wp-content/themes