0

I can access files inside a LXD container by running lxc from the host:

root@Host# lxc exec Container_Name bash
root@Container_Name# touch /tmp/hello

Or by accessing the files directly from the host under /var/lib/lxd/containers/Container_Name/rootfs:

root@Host# touch /var/lib/lxd/containers/Container_Name/rootfs/tmp/hello

Is there a preferred way?

  • Depends on what do you want to achieve. If you only want to create a file, the second example is totally fine. If you want to automate this process for multiple containers, have a look at cloud-init. – J. Pee Jul 15 '18 at 20:45
0

You should use the exec command so that permissions will be set according to the user/group mapping of the container.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.