Docker WordPress can’t update/install plugins

After a bit of digging, the problem is with this line that I added in my config.php that removed the missing FTP error when I started the container:

define('FS_METHOD', 'direct');

After that I tried many times to chown the directories of the site, with no success. Which is strange because I used the root account to change them. However they remained to group users.

In the end I added the www-data user to users and root (just in case) groups and that solved the problem.

usermod -a -G users www-data
usermod -a -G root www-data

Update

Another solution I found is instead of using a bind volume ./wordpress to use normal volume wordpress with read/write permissions. Here is the new docker-compose:

wordpress:
        depends_on: 
            - database
        links: 
            - database
        image: wordpress:latest
        restart: always
        read_only: false
        ports: 
            - '8000:80'
        environment: 
            WORDPRESS_DB_HOST: database:3306
            WORDPRESS_DB_USER: user
            WORDPRESS_DB_PASSWORD: password
            WORDPRESS_DB_NAME: database
        volumes: 
            - wordpress:/var/www/html:rw

After the mentioned change the output of ls -l for the folders is like this:

-rw-r--r-- 1 www-data www-data   405 Feb  6  2020 index.php
-rw-r--r-- 1 www-data www-data 19915 Jan  1  2021 license.txt
-rw-r--r-- 1 www-data www-data  7345 Dec 29  2020 readme.html
-rw-r--r-- 1 www-data www-data  7165 Jan 21 01:37 wp-activate.php
drwxr-xr-x 1 www-data www-data  2668 May 12 23:49 wp-admin
-rw-r--r-- 1 www-data www-data   351 Feb  6  2020 wp-blog-header.php
-rw-r--r-- 1 www-data www-data  2328 Feb 17 13:08 wp-comments-post.php
-rw-rw-r-- 1 www-data www-data  5456 Jul  2 02:02 wp-config-docker.php
-rw-r--r-- 1 www-data www-data  2913 Feb  6  2020 wp-config-sample.php
-rw-r--r-- 1 www-data www-data  5560 Jul 15 07:30 wp-config.php
drwxr-xr-x 1 www-data www-data    54 May 12 23:49 wp-content
-rw-r--r-- 1 www-data www-data  3939 Jul 30  2020 wp-cron.php
drwxr-xr-x 1 www-data www-data  8378 May 12 23:49 wp-includes
-rw-r--r-- 1 www-data www-data  2496 Feb  6  2020 wp-links-opml.php
-rw-r--r-- 1 www-data www-data  3313 Jan 10  2021 wp-load.php
-rw-r--r-- 1 www-data www-data 44994 Apr  4 18:34 wp-login.php
-rw-r--r-- 1 www-data www-data  8509 Apr 14  2020 wp-mail.php
-rw-r--r-- 1 www-data www-data 21125 Feb  2 00:10 wp-settings.php
-rw-r--r-- 1 www-data www-data 31328 Jan 27 21:03 wp-signup.php
-rw-r--r-- 1 www-data www-data  4747 Oct  8  2020 wp-trackback.php
-rw-r--r-- 1 www-data www-data  3236 Jun  8  2020 xmlrpc.php

Now wordpress updates/installs plugins and the update of wordpress itself is working flawlessly.

Leave a Comment