I am currently working on converting my FOG server from OpenVZ to LXC. I am no expert, but here is what I did to get the NFS Server running inside the container.
I run Proxmox 4.x but this should work for LXC in general. These instructions are from a post on the Proxmox Forum (https://forum.proxmox.com/threads/advice-for-file-sharing-between-containers.25704/#post-129006) and tweaked just a little.
LXC OS: Ubuntu 16.04
FOG Version: 1.3.0 (pulled from git)
By default LXC has Apparmor enabled. There are two choices here, disable Apparmor or create a profile to allow NFS. I do not recommend disabling Apparmor, but it can be helpful for testing purposes.
Option 1 - Disable Apparmor:
- Edit the container configuration file and add the line
lxc.aa_profile: unconfined
.
On Proxmox the configuration file is located at/etc/pve/lxc/CTID.conf
, where CTID is the ID number of the container.
Option 2 - Create an Apparmor profile that allows NFS:
- Create the file
/etc/apparmor.d/lxc/lxc-default-with-nfs
with the following content.
# Do not load this file. Rather, load /etc/apparmor.d/lxc-containers, which
# will source all profiles under /etc/apparmor.d/lxc
profile lxc-container-default-with-nfs flags=(attach_disconnected,mediate_deleted) { #include <abstractions/lxc/container-base>
# allow NFS (nfs/nfs4) mounts.
mount fstype=nfs*,
mount fstype=rpc_pipefs,
}
- Reload Apparmor:
apparmor_parser -r /etc/apparmor.d/lxc-containers
- Edit the container configuration file and add the line
lxc.aa_profile: lxc-container-default-with-nfs
.
On Proxmox the configuration file is located at/etc/pve/lxc/CTID.conf
, where CTID is the ID number of the container.
Make sure to restart your container after you make any changes to the configuration file.
Hope this helps!