Trying to use the NFS
plugin with a synced folder in Vagrant, and it is working, except that in the guest (VM) the permissions are wrong:
-rw-r--r-- 1 501 dialout 0 Jan 20 00:51 a
-rw-r--r-- 1 501 dialout 0 Jan 20 00:51 foo
I tried setting up the uid
and gid
according to the Vagrant documentation in the Vagrantfile
:
config.nfs.map_uid = 1001
config.nfs.map_gid = 1001
Which I was hoping would use the correct user/group in the guest, but it is still using 501
and dialout
.
Any ideas?
This worked for me on a MacOS Catalina host and Ubuntu 18.04 guest (Vagrant 2.2.9, VirtualBox 6.1.12):
opts = {
type: 'nfs',
linux__nfs_options: ['no_root_squash'],
map_uid: 0,
map_gid: 0
}
config.vm.synced_folder '.', '/var/www/project', opts
You can then chown
and chmod
as usual:
$ sudo chown -R vagrant:vagrant /var/www/project
$ sudo chmod -R 774 /var/www/project/logs
ATTENTION: no_root_squash
is fine for development environments, but DON'T use it for production. It allows remote root users to change any file in the shared file system.
Another option might be to use the vagrant-bindfs plugin. But I didn't feel like installing and configuring an extra plugin for this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With