Vagrant Synced Folders


#1

In vagrant.default.yml, while using vagrant_synced_folders, the destination folder is set as owner:root, group:root and I can’t figure out how to change it. I’ve tried a number of mount_options, but no luck. Is there a way to have the vagrant synced folder destination to be set as owner:vagrant, group:www-data (or anything else)?


#2

Please share with us what you’ve tried if you’re looking for help :slight_smile:


#3

I’ve tried what they’ve suggested:

mount_options: ['uid=1000', 'gid=33']

and get this error:

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o vers=3,udp,uid=1000,gid=33 192.168.50.1:/Volumes/...

Stdout from the command:



Stderr from the command:

mount.nfs: an incorrect mount option was specified

#4

Here’s an example that works for me.

# example directory structure
example.com
├── site
├── test
└── trellis
# excerpt from vagrant.default.yml
vagrant_synced_folders:
  - local_path: ../test
    destination: /test
    create: false
    type: nfs
    bindfs: true
    bindfs_options:
      o: 'nonempty'
      p: '0644,a+D'
      u: 'vagrant'
      g: 'www-data'
# reload sync folders
$ vagrant reload

# SSH into VM
$ vagrant ssh

# Check ownership of /test dir
$ ls -lh / | grep test
drwxr-xr-x   3 vagrant www-data  102 Nov  6 02:52 test

#5

That worked, thank you so much!