For some reason, I am neither able to mount or share via NFS in an LXC container, I'm using Proxmox 4.1 and the guest os is Debian 8
I also tried to mount smb and got the same result. is this a thing? that these things can't be done in a container? or is it just me?
It works when I do it in a KVM though.
What are you trying to access with NFS? if it is a directory on the host machine you can add lxc.mount.entry = /host/directory lxc/directory none rw,bind 0.0 to /var/lib/lxc/config or alternatively, if the NFS share is on another machine you can mount it on the host anad direct it to the container. That is the only way I've got it working so far as I've also had trouble getting NFS to work in an lxc container.
Thanks! I'm actually trying to mount a share in another computer, but that host mounting trick seems nice. I'll give it a try.
should I create a file in "/var/lib/lxc/config"?
and how do I specify which lxc to direct to?
Ah my mistake, you need to edit /var/lib/lxc/container-name/config.
I edited /var/lib/lxc/100/config and put in ot lxc.mount.entry = /mnt/nfs_data /mnt/nfs_data none rw,bind 0.0 but didn't work
You have to exclude the forward slash on the containers directory to /mnt/nfs_data mnt/nfs_data.
ok done that but still nothing changed
Did you restart the container afteryou made the changes?
yes, I double checked the nfs mount on the host but there were no files in the container
I just remembered that you have to create the directory on the container before you configure the mount point. Not doing so would throw this error:
lxc-start 20160504165457.321 ERROR lxc_conf - conf.c:mount_entry:1650 - No such file or directory - failed to mount '/mnt/nfs_data' on '/usr/lib/x86_64-linux-gnu/lxc/mnt/nfs_data'
I was reconfiguring one of my containers and ran into this issue before I remembered.
When trying to mount an NFS where one lxc container was the server and another was the client, I had to put this
lxc.aa_profile = unconfined
In the /var/lib/lxc/${CONTAINER_NAME_HERE}/config
Otherwise the NFS wouldn't mount.
Any changes to lxc config are gone after reboot, is there a solution to this?