Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to install plugins when using bind or volumes rw docker #415

Closed
majerus1223 opened this issue Jul 17, 2019 · 4 comments
Closed

Unable to install plugins when using bind or volumes rw docker #415

majerus1223 opened this issue Jul 17, 2019 · 4 comments
Labels
question Usability question, not directly related to an error with the image

Comments

@majerus1223
Copy link

majerus1223 commented Jul 17, 2019

When using docker compose as shown below with bind volumes you cannot install plugins without modifying wp-config.php and setting define( 'FS_METHOD', 'direct' ); . Even when you create the directories manually, chown -R 33:33 then chmod 644 -R you cannot install plugins as you encounter an error. This seems to lead to inconstancy where if you use the FS_Method, direct some plugins misbehave. Where is the code that is doing the permissions checking on the /var/www/html and causing Wordpress to act this way?

Error: 
Connection Information
To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Hostname 
example: www.wordpress.org
FTP Username 
user
FTP Password 
••••••••••••••••••
This will not be stored on the server.
Connection Type
 FTP
 FTPS (SSL)
services:
  db:
    image: mysql:5.7
    volumes:
      - ./db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress
    

  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - "8000:80"
    restart: always
    volumes:
      - ./wp:/var/www/html
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_DB_NAME: wordpress
    

Thanks!

@wglambert wglambert added the question Usability question, not directly related to an error with the image label Jul 17, 2019
@wglambert
Copy link

Duplicate of #298 (comment) and #397 (comment)

If you're adding define('FS_METHOD', 'direct'); make sure you do that before the container is running, there isn't a control loop checking for changes to the config.
You'll also want to adjust the mounted folder's permissions on the host, which gets replicated to the container.
Using your docker-compose.yml works just fine if you mkdir wp && sudo chown 33:33 ./wp before initializing

Adding and activating a few plugins:
wurdpres

Checking the mounted folder on the host:

$ ls
db_data/  docker-compose.yml  wp/

$ ls -l wp/wp-content/plugins/
total 16
drwxr-xr-x 4 www-data www-data 4096 Jun 18 10:51 akismet/
drwxrwxr-x 6 www-data www-data 4096 Jul 17 13:44 gutenberg/
-rw-r--r-- 1 www-data www-data 2578 Mar 18 10:19 hello.php
-rw-r--r-- 1 www-data www-data   28 Jun  5  2014 index.php

@majerus1223
Copy link
Author

majerus1223 commented Jul 18, 2019

Thanks for validating that it worked. After seeing that you were able to make it work I keep messing with it and what it appears to be is an issue with NFS.

The ./wp directory in my case resides on /mnt/Docker_Share/Wordpress/wp . /mnt/Docker_Share is mounted via nfs using /etc/fstab with your typical mount options nothing special.

For testing I did the following.
mkdir /tester
mkdir /tester/wp && chown 33:33 /tester/wp
docker-compose up

Then ran though the installer quickly, and installed a plugin which worked.

Is there a way to test and understand why NFS is causing an issue here? I have a slew of other containers with mounted volumes on the same mount without a problem.

@wglambert
Copy link

How are your NFS permissions set? #389 (comment)

@kasparsd
Copy link

@majerus1223 Bind mounted volumes will make the whole directory tree on the container inherit the file permissions of the host filesystem. So you need to ensure that Apache is running with a user ID that permissions to write to those files.

Use the APACHE_RUN_USER environment variable to set the required user ID like so:

  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - "8000:80"
    restart: always
    volumes:
      - ./wp:/var/www/html
    environment:
      APACHE_RUN_USER: "#33"
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_DB_NAME: wordpress

Note that the leading hash before 33 is required for this work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

3 participants