====== LXC - Mount a directory on host into the Container ======
===== Get your uid on the host =====
id
returns:
uid=1000(peter) gid=1000(peter) groups=1000(peter)
**NOTE:** On Ubuntu the uid of the first user is usually 1000.
----
===== Allow LXD to remap to this id =====
echo 'root:1000:1' | sudo tee -a /etc/subuid /etc/subgid
----
===== Create a container =====
lxc init ubuntu-daily:z test
----
===== Set up the idmap to map both uid and gid 1000 to uid and gid 1000 inside the container =====
lxc config set test raw.idmap 'both 1000 1000'
----
===== Set the host directory to be mounted in the container =====
lxc config device add test homedir disk source=/home/peter path=/home/ubuntu
----
===== Start the container =====
lxc start test
----
===== Check the shared directory in the container =====
lxc exec test ls /home/ubuntu/
**NOTE:** This should display any file in the directory that was mapped.