ubuntu_lxc_lxd
Table of Contents
Ubuntu - LXD containers
Basics
The LXD container hypervisor. Info: https://www.ubuntu.com/containers/lxd
- Install LXD:
apt-get install lxd
- Initialize LXD:
lxd init
- Create a new containter:
lxc launch ubuntu: <container-name>
lxc launch images:centos/7/amd64 <container-name>
- List containers:
lxc list +---------+---------+--------------------------------+-----------------------------------------------+------------+-----------+ | NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | +---------+---------+--------------------------------+-----------------------------------------------+------------+-----------+ | c1 | RUNNING | 1.2.3.4 (eth0) | fd42:dd7c:afec:9008:216:3eff:aaaa:aaaa (eth0) | PERSISTENT | 0 | +---------+---------+--------------------------------+-----------------------------------------------+------------+-----------+ | c2 | RUNNING | 1.2.3.5 (eth0) | fd42:dd7c:afec:9008:216:3eff:bbbb:bbbb (eth0) | PERSISTENT | 0 | +---------+---------+--------------------------------+-----------------------------------------------+------------+-----------+ | c3 | RUNNING | 1.2.3.6 (eth0) | fd42:dd7c:afec:9008:216:3eff:cccc:cccc (eth0) | PERSISTENT | 0 | +---------+---------+--------------------------------+-----------------------------------------------+------------+-----------+
- Modify DHCP range:
lxc network set lxdbr0 ipv4.dhcp.ranges 1.2.3.100-1.2.3.150
- Start shell in container:
lxc exec c1 bash
Bridge
Configure an unused interface for bridging with containers.
- Install bridge utilities:
apt install bridge-utils
- Configure bridge interface:
tee -a /etc/network/interfaces.d/br0 <<EOF auto br0 iface br0 inet manual bridge_ports enp3s0 bridge_stp off bridge_fd 0 bridge_maxwait 0 EOF
- Show default settings:
lxc profile show default config: {} description: Default LXD profile devices: eth0: nictype: bridged parent: lxdbr0 type: nic root: path: / pool: default type: disk name: default used_by: []
- Edit parent NIC:
lxc profile edit default
ubuntu_lxc_lxd.txt · Last modified: 2021/10/09 15:14 by 127.0.0.1