Docker Community Forums

Share and learn in the Docker community.

Docker NFS persistent volume, wordpress error 'Unable to connect to the filesystem.'

My issue:
I’m not able to install any wordpress plugins, I get this error Unable to connect to the filesystem. Please confirm your credentials. This seems like a permissions issue, or something to do with the NFS bind. There are no errors.

I’m able to upload media without a problem.

I’m probably just doing something wrong, or I don’t understand how this docker image works. I hope someone can point me in the right direction. Or give me an suggestion on how to run this stack with a persistent volume for wordpress.

My goal:
Running this stack on a docker swarm (raspberry pi’s) with a persistent volume using NFS. So the wordpress container can run on any node in the cluster. Same goes for the mysql container.

Information
Docker-compose.yml

version: '3.2'

services:
   db:
    image: mariadb
    volumes:
      - db_data:/var/lib/mysql
    environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
    image: wordpress
    depends_on:
       - db
    volumes:
      - wp_content:/var/www/html
    ports:
       - "80:80"
    environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
       WORDPRESS_DB_NAME: wordpress

volumes:
  db_data:
    driver_opts:
      type: "nfs"
      o: "addr=192.168.1.245,nolock,soft,rw"
      device: ":/vol/mysql"
  wp_content:
    driver_opts:
      type: "nfs"
      o: "addr=192.168.1.245,nolock,soft,rw"
      device: ":/vol/wordpress"

nfs-server export file

/vol *(rw,sync,no_subtree_check,insecure,all_squash,anonuid=0,anongid=0)

File permissions in /vol

drwxrwxrwx  4 root     root     4096 Mar 10 14:59 .
drwxr-xr-x 26 root     root     4096 Mar 10 10:00 ..
drwxr-xr-x  5      999      999 4096 Mar 10 15:18 mysql
drwxrwxrwx  5 www-data www-data 4096 Mar 10 15:17 wordpress

File permissions in /vol/wordpress

drwxrwxrwx  5 www-data www-data  4096 Mar 10 15:17 .
drwxrwxrwx  4 root     root      4096 Mar 10 14:59 ..
-rw-r--r--  1 www-data www-data   235 Mar 10 15:26 .htaccess
-rw-r--r--  1 www-data www-data   420 Nov 30  2017 index.php
-rw-r--r--  1 www-data www-data 19935 Jan  1 20:37 license.txt
-rw-r--r--  1 www-data www-data  7425 Jan  9 02:56 readme.html
-rw-r--r--  1 www-data www-data  6919 Jan 12 06:41 wp-activate.php
drwxr-xr-x  9 www-data www-data  4096 Feb 21 22:09 wp-admin
-rw-r--r--  1 www-data www-data   369 Nov 30  2017 wp-blog-header.php
-rw-r--r--  1 www-data www-data  2283 Jan 21 01:34 wp-comments-post.php
-rw-r--r--  1 www-data www-data  3088 Mar 10 15:17 wp-config.php
-rw-r--r--  1 www-data www-data  2808 Mar 10 15:17 wp-config-sample.php
drwxr-xr-x  5 www-data www-data  4096 Mar 10 15:42 wp-content
-rw-r--r--  1 www-data www-data  3847 Jan  9 08:37 wp-cron.php
drwxr-xr-x 19 www-data www-data 12288 Feb 21 22:09 wp-includes
-rw-r--r--  1 www-data www-data  2502 Jan 16 05:29 wp-links-opml.php
-rw-r--r--  1 www-data www-data  3306 Nov 30  2017 wp-load.php
-rw-r--r--  1 www-data www-data 38883 Jan 12 06:41 wp-login.php
-rw-r--r--  1 www-data www-data  8403 Nov 30  2017 wp-mail.php
-rw-r--r--  1 www-data www-data 17947 Jan 30 11:01 wp-settings.php
-rw-r--r--  1 www-data www-data 31085 Jan 16 16:51 wp-signup.php
-rw-r--r--  1 www-data www-data  4764 Nov 30  2017 wp-trackback.php
-rw-r--r--  1 www-data www-data  3068 Aug 17  2018 xmlrpc.php

The problem still inside to container, seems you do not have permission to write on.
try to enter in -it on your Wordpress container and try to write a file on the /var/www/html with the user: www-data
If you cannot, this probably depend from nfs who do not permit it.
Ping back me if you still to have problem.

Running this command to get inside the container docker exec -it --user www-data 2901c1629537 bash

Then I ran this command www-data@2901c1629537:~/html$ mkdir -p /var/www/html/dockerforum
As you can see the owner of the file is root, but it should be www-data.
Output of ls -la

www-data@2901c1629537:~/html$ ls -la
total 220
drwxrwxrwx  6 www-data www-data  4096 Mar 11 12:27 .
drwxr-xr-x  1 root     root      4096 Mar  5 14:45 ..
-rw-r--r--  1 www-data www-data   235 Mar 10 20:27 .htaccess
drwxr-xr-x  2 root     root      4096 Mar 11 12:27 dockerforum
-rw-r--r--  1 www-data www-data   420 Nov 30  2017 index.php
-rw-r--r--  1 www-data www-data 19935 Jan  1 20:37 license.txt
-rw-r--r--  1 www-data www-data  7425 Jan  9 02:56 readme.html
-rw-r--r--  1 www-data www-data  6919 Jan 12 06:41 wp-activate.php
drwxr-xr-x  9 www-data www-data  4096 Feb 21 22:09 wp-admin
-rw-r--r--  1 www-data www-data   369 Nov 30  2017 wp-blog-header.php
-rw-r--r--  1 www-data www-data  2283 Jan 21 01:34 wp-comments-post.php
-rw-r--r--  1 www-data www-data  2808 Mar 11 12:20 wp-config-sample.php
-rw-r--r--  1 www-data www-data  3088 Mar 11 12:20 wp-config.php
drwxr-xr-x  5 www-data www-data  4096 Mar 11 12:24 wp-content
-rw-r--r--  1 www-data www-data  3847 Jan  9 08:37 wp-cron.php
drwxr-xr-x 19 www-data www-data 12288 Feb 21 22:09 wp-includes
-rw-r--r--  1 www-data www-data  2502 Jan 16 05:29 wp-links-opml.php
-rw-r--r--  1 www-data www-data  3306 Nov 30  2017 wp-load.php
-rw-r--r--  1 www-data www-data 38883 Jan 12 06:41 wp-login.php
-rw-r--r--  1 www-data www-data  8403 Nov 30  2017 wp-mail.php
-rw-r--r--  1 www-data www-data 17947 Jan 30 11:01 wp-settings.php
-rw-r--r--  1 www-data www-data 31085 Jan 16 16:51 wp-signup.php
-rw-r--r--  1 www-data www-data  4764 Nov 30  2017 wp-trackback.php
-rw-r--r--  1 www-data www-data  3068 Aug 17  2018 xmlrpc.php

I think this has to do with the all_squash,anonuid=0,anongid=0 in the nfs export.

you understand well.
you should modify export parameters:

(rw,all_squash,anonuid=33,anongid=33)

Have a good day.
Let me know if will works.

Yes, thank you that worked. I still had to add the insecure option to the NFS export. I think because docker connect from a really high port.

I also made 2 separate exports, 1 for mysql and 1 for wordpress. The mysql image uses user 999, and the wordpress image uses user 33. Thanks for your help.