I getting permission issues (or so it appears) on a bind mounted volume on a Mac that is preventing themes and plugins from being installed. I'm using docker-compose to create my container as follows.
wordpress:
depends_on:
- db
image: wordpress
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: *****
WORDPRESS_DB_NAME: wordpress
working_dir: /var/www/html
volumes:
- ./wp-content:/var/www/html/wp-content
The Container is created no problem. On my host mac the wp-content
directory is created just fine and correctly populated. I can connect to my container (using docker exec
) and see the mounted volume has default permissions of drwxr-xr-x 1 1000 staff 160 Aug 14 23:04 wp-content
Whenever I try to install a theme or plugin it prompts for FTP credentials or if I add define('FS_METHOD', 'direct')
to wp-config.php
fails with "Could not create directory". I've also tried making permissions to wp-config
from my host host wide open with chmod -R 777 wp-content
and changing ownership from the container with chown -r www-data:www-data wp-content
. Enabling debugging produces no debug.log
in wp-content
. I've also tried running apache as user 1000 using user: "1000:1000"
and/or environment: APACHE_RUN_USER/APACHE_RUN_GROUP
as per https://github.com/docker-library/wordpress/pull/249 . Nothing seems to make any difference and I have no idea what to try next. I suspect this is something really simple but have exhausted everything I can find. Any tips or help would be greatly appreciated. I'm just trying to do some basic plugin development and would like to edit wp-content
locally.
I think you need to make volume from the root directory of your wordpress install. There is my docker-compose.yml file
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: dbname
MYSQL_USER: dbuser
MYSQL_PASSWORD: dbpassword
wordpress:
depends_on:
- db
image: wordpress:latest
volumes:
- wp_data:/var/www/html
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: dbuser
WORDPRESS_DB_PASSWORD: dbpassword
WORDPRESS_DB_NAME: dbname
volumes:
db_data: {}
wp_data:
driver: local
driver_opts:
type: none
o: bind
device: /var/www/html/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.