sudo apt install lxc
sudo snap install lxd
lxd init
The defaults will be fine for personal use, and we can name our pool whatever we like.
lxc list
lxc list -c n,s,4,image.description:image
lxc launch ubuntu:20.04 FirstContainer
lxc launch images:alpine/edge/default AlpineContainer
lxc image alias list ubuntu:
lxc image alias list images: 'alpine'
lxc info FirstContainer
In container:
cat /etc/os-release
lxc exec FirstContainer bash
lxc exec AlpineContainer sh
lxc exec FirstContainer hostname
lxc stop FirstContainer
lxc delete FirstContainer
lxc copy AlpineContainer AlpineContainer2
lxc start AlpineContainer2
- In container:
nano /etc/ssh/sshd_config
PasswordAuthentication yes
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes
systemctl restart ssh
If password is not 'ubuntu', use passwd root to change the password.
- On host:
ssh-keygen -b 2048 -t rsa -C steven.d.hondt.sdh@gmail.com ssh-copy-id -i .ssh/id_rsa.pub root@10.8.18.147
nano .ssh/config
Host first
HostName 10.8.18.147
user root
IdentityFile ~/.ssh.id_rsa
ssh first
If the container doesn't have ssh, like the alpine container:
apk add openssh
rc-update add sshd
/etc/init.d/sshd start
Then go through the previous steps...
lxc file push /path/to/file FirstContainer/path/to/destination/for/file
lxc file pull FirstContainer/path/to/file /path/to/destination/for/file
lxc file edit FirstContainer/path/to/file
lxc snapshot FirstContainer
lxc restore FirstContainer snap0
lxc delete FirstContainer/snap0
cd /etc/netplan
ls
nano name-of-netplan.yaml
network:
version: 2
rederer: networkd
ethernets:
eth0:
dhcp4: false
dhcp6: false
bridges:
br0:
interfaces: [eth0]
dhcp4: true
lxc config device add FirstContainer eth0 nic nictype=bridged parent=br0 name=eth0
lxc restart FirstContainer