Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
tips:lxd [2017/11/21 11:14] – [share folder] scipio | tips:lxd [2019/11/19 19:12] (current) – [container] scipio | ||
---|---|---|---|
Line 5: | Line 5: | ||
< | < | ||
- | sudo add-apt-repository --yes ppa: | + | apt remove lxd lxd-client |
- | sudo apt update | + | snap install lxd |
- | sudo apt install lxd | + | |
# create zfs dataset on pool rpool | # create zfs dataset on pool rpool | ||
Line 129: | Line 128: | ||
lxc list | lxc list | ||
</ | </ | ||
+ | |||
+ | create custom image from local container | ||
+ | < | ||
+ | lxc publish local-container --alias mycustomimage | ||
+ | </ | ||
+ | |||
+ | create container from previous image | ||
+ | < | ||
+ | lxc launch mycustomimage newcontainer | ||
+ | </ | ||
+ | |||
+ | |||
bash inside | bash inside | ||
Line 162: | Line 173: | ||
</ | </ | ||
+ | |||
+ | ===== network ===== | ||
+ | |||
+ | < | ||
+ | lxc network create br0 | ||
+ | lxc network show br0 | ||
+ | lxc network edit br0 | ||
+ | </ | ||
+ | |||
+ | static IP container | ||
+ | < | ||
+ | istance=c1 | ||
+ | |||
+ | lxc stop $instance | ||
+ | lxc network attach lxdbr0 $istance eth0 eth0 | ||
+ | lxc config device set $istance eth0 ipv4.address 10.99.10.42 | ||
+ | lxc start $istance | ||
+ | </ | ||
===== servers ===== | ===== servers ===== | ||
Line 192: | Line 221: | ||
<code bash> | <code bash> | ||
NAME=x11test | NAME=x11test | ||
- | lxc launch images: | + | lxc launch images: |
</ | </ | ||
Line 198: | Line 227: | ||
<code bash> | <code bash> | ||
lxc exec $NAME -- apt install xterm | lxc exec $NAME -- apt install xterm | ||
+ | lxc exec $NAME bash | ||
+ | apt install mesa-utils x11-apps | ||
</ | </ | ||
- | set DISPLAY env to xorg server on host | + | |
- | < | + | < |
- | lxc config set x11test | + | NAME=nvidia-sdk-manager |
+ | # lxc config set $NAME environment.DISPLAY < | ||
+ | lxc config set $NAME environment.DISPLAY :0 | ||
+ | lxc config device add $NAME X0 disk path=/ | ||
+ | lxc config device add $NAME Xauthority disk path=/ | ||
</ | </ | ||
Line 252: | Line 287: | ||
echo " | echo " | ||
echo " | echo " | ||
+ | lxc profile set default security.privileged true | ||
# for every share | # for every share | ||
# lxc init stretch giano | # lxc init stretch giano | ||
+ | lxc config set gianocop security.privileged true | ||
lxc config set giano raw.idmap "both $UID $UID" | lxc config set giano raw.idmap "both $UID $UID" | ||
# source is on host, path is inside container | # source is on host, path is inside container | ||
Line 289: | Line 326: | ||
volatile.last_state.power: | volatile.last_state.power: | ||
</ | </ | ||
+ | ===== export image from container ===== | ||
+ | {{tag> | ||
+ | |||
+ | |||
+ | ===== Vlan attach ===== | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | |||
+ | < | ||
+ | |||
+ | < | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | auto eth1.10 | ||
+ | iface eth1.10 inet static | ||
+ | address 10.0.0.1 | ||
+ | netmask 255.255.255.0 | ||
+ | vlan-raw-device eth1 </ | ||
+ | |||
+ | ===== Send file to your new host ===== | ||
+ | |||
+ | On image hosts | ||
+ | |||
+ | < | ||
+ | example | ||
+ | < | ||
+ | |||
+ | Export image | ||
+ | < | ||
+ | |||
+ | Output is in efaa243331f0a7c175376edaf796545a01ad09bb47f25a297b798e09fe66ee66.tar.gz | ||
+ | Show size of export | ||
+ | < | ||
+ | |||
+ | ==== check sum of image ==== | ||
+ | |||
+ | < | ||
+ | md5sum efaa243331f0a7c175376edaf796545a01ad09bb47f25a297b798e09fe66ee66.tar.gz > exportmd5.txt | ||
+ | |||
+ | cat exportmd5.txt | nc 10.18.49.73 1234 | ||
+ | |||
+ | cat efaa243331f0a7c175376edaf796545a01ad09bb47f25a297b798e09fe66ee66.tar.gz | nc 10.18.49.73 1234 | ||
+ | </ | ||
+ | **NB**: 10.18.49.73 is your new lxd host | ||
+ | |||
+ | 1234 is a free port | ||
+ | |||
+ | ===== Transfer image and checksum to new LXD host ===== | ||
+ | < | ||
+ | nc -l 1234 > efaa243331f0a7c175376edaf796545a01ad09bb47f25a297b798e09fe66ee66.tar.gz | ||
+ | nc -l 1234 > exportmd5.txt </ | ||
+ | |||
+ | check file | ||
+ | < | ||
+ | md5sum efaa243331f0a7c175376edaf796545a01ad09bb47f25a297b798e09fe66ee66.tar.gz | ||
+ | md5sum -c exportmd5.txt | ||
+ | </ | ||
+ | |||
+ | ===== Import image to new LXD host ====== | ||
+ | |||
+ | < | ||
+ | |||
+ | Transferring image: 100% | ||
+ | |||
+ | < | ||
+ | Creating container_name | ||
+ | Starting container_name | ||
+ | |||
+ | In some instances the publish command may lead to a split xz tar-ball --- but both formats are supported. Simply import the meta-data and rootfs components with | ||
+ | |||
+ | lxc image import < | ||
+ | === Edit LXD default profile: networking === | ||
+ | |||
+ | Put lxc network interface to host network | ||
+ | |||
+ | < | ||
+ | lxc stop lxc-docuwiki | ||
+ | lxc profile device set default eth0 parent ens3 | ||
+ | lxc profile device set default eth0 nictype macvlan | ||
+ | service lxd restart | ||
+ | service lxd-containers restart </ | ||
+ | |||
+ | launch your container | ||
+ | < | ||
+ | lxc start lxc-docuwiki | ||
+ | lxc exec lxc-docuwiki /bin/bash | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||