The way to do it is to add a device to the LXC container of the form
devices:
<localhsarename>:
path: <hosting_server_path>
type: disk
There are two ways to do it.
1) From the command line. The manual states
$ lxc profile device add --help
Description:
Add instance devices
Usage:
lxc profile device add [<remote>:]<profile> <device> <type> [key=value...] [flags]
Examples:
lxc profile device add [<remote>:]profile1 <device-name> disk source=/share/c1 path=/opt
Will mount the host's /share/c1 onto /opt in the instance.
So, to mount the host’s /wwwdata/ directory onto /var/www/html/ in the LXD container named c1, run:
lxc config device add c1 sharedwww disk source=/wwwdata/ path=/var/www/html/
2) A second way to do it is to create a profile with that in it as (with the same data)
devices:
lxcshare:
path: /var/www/html
source: /wwwdata
type: disk
You can create the profile with
lxc profile edit sharedir
then when creating the container use that profile e.g.
lxc launch ubuntu:22.04/amd64 <containername> -p sharedir -p default
- Log in to post comments