Search code examples
mysqldockernfsdocker-volume

Docker nfs volume mysql - How to fix: "failed to copy file info"


I created a "mysql" service with docker-compose with a nfs volume. The service does not start and gives the following error:


"failed to copy file info for /var/lib/docker/volumes/db_data/_data: failed to chown /var/lib/docker/volumes/db_data/_data: lchown /var/lib/docker/volumes/db_data/_data: operation not permitted" 


I tried with "couchdb" but it has the same problem

below is a piece of example code:

version: "3.7"
networks:
  web:
    external: true
services:
  db:
    image: mysql:5.7
    networks:
      - web
    environment:
      MYSQL_ROOT_PASSWORD: xxxxxx
      MYSQL_DATABASE: xxxxxx
      MYSQL_USER: xxxxxx
      MYSQL_PASSWORD: xxxxxx
    volumes:
      - db_data:/var/lib/mysql
volumes:
  db_data:
    driver_opts:
      type: nfs
      o: addr=x.x.x.x,nolock,soft,rw
      device: :/var/nfs/db_data

What is the correct and best way to make it work?


Solution

  • Try to fix it from the server side! On the NFS server, check the "/etc/exports" file. You should have something like this:

    /var/nfs/db_data x.x.x.x/24(rw,sync,no_subtree_check)
    

    Try adding the "no_root_squash" option:

    /var/nfs/db_data x.x.x.x/24(rw,sync,no_root_squash,no_subtree_check)