A simple way to move a container to another host.
Containers are located /var/lib/lxd/containers/
for example, to move container xxx
$tar cxvf xxx.tar.gz /var/lib/lxd/containers/xxx
$scp xxx.tar.gz user@remotehost:/home/user
At remote host, unpack files /var/lib/lxd/containers/
Then
$sudo lxc image import xxx
The container setup a shared folder before. After moving to a new host, it can't start because of this.
There is no /etc/subuid and /etc/subgid
Note: $UID is likely to be 1000 on an Ubuntu system if you're the only user.
$echo "root:$UID:1" | sudo tee -a /etc/subuid /etc/subgid
After this, the container can start.
The following is how to create a shared folder device in container
$ sudo lxc config device add xxx projectdir disk source=/home/user/prjs path=/home/user/prjs
Then set idmap
$sudo lxc stop xxx
$sudo lxc config set xxx raw.idmap 'both 1000 1000'
$sudo lxc start xxx
没有评论:
发表评论