There is much information already about how to mount a directory from the LXD host into a container, thus allowing access to external resources. I cannot though figure out how to do this from a snap based LXD.
root@dev5:~# lxc version
Client version: 3.7
Server version: 3.7
Hi: I was trying to mount a directory into my container using lxc version 3.0.3 and this was very helpful for me. But just in case anyone else comes here looking, there’s another step that I had to do to get this to work, as I was otherwise getting ‘touch: cannot touch ‘myfiles.txt’: Permission denied’ error from within the container, and a quick ls -la showed me why:
drwxr-xr-x 2 nobody nogroup 4096 Jun 3 02:35 .
drwx------ 5 root root 8 Jun 3 02:36 …
the container user lacked the permission to create a file (you can read, but not write)!
So, since I wanted to be able to write, I fixed this with permission changes as follows (you might want to use less liberal permissions, but you get the idea I trust). On the host:-
mkdir ~/LXDSHARED
chmod -R 0777/LXDSHARED
Then you can execute the ‘lxc config …’ as shown and gain read AND write-access to the directory.