There is a lot of misleading information out there to solve a very simple problem.
This will allow you to create what would normally be a nfs share between two machines.
There have been many updates to lxc and many ways reported to work, this way worked perfectly for me on the first try
and the directories where writable from both machines.
Containers
- stagingweb01
- stagingweb02
Shares:
- /mnt/nfs/tmp/media
- /mnt/nfs/media*
Command structure as seen from:
lxc config help
lxc config device add [remote:]container1 <device-name> disk source=/share/c1 path=opt
Commands to run on the host machine note there is NO need to create these directories on the containers, but if they exist it will work the same way:
Commands to run on the host
- sudo lxc config device add stagingweb01 sdb disk source=/mnt/nfs/tmp/media path=mnt/nfs/tmp/media
- sudo lxc config device add stagingweb01 sdb1 disk source=/mnt/nfs/media path=mnt/nfs/media
- sudo lxc config device add stagingweb02 sdb disk source=/mnt/nfs/tmp/media path=mnt/nfs/tmp/media
- sudo lxc config device add stagingweb02 sdb1 disk source=/mnt/nfs/media path=mnt/nfs/media
Very important Due to a change in LXC on Sept of 2015 the paths need to be relative on the host side, but they will be created on the root
I am not able to create/update any file on the shared/mounted directory. I know I can make the directory a Read/Write all of 777 and that solves the problem but I dont want to do that as one folder belongs to one container only and I want to maintain some level of security. Is there any solution for my particular problem ?