Ben's notes

Linux, Unix, network, radio...

User Tools

Site Tools


ubuntu_lxc_lxd

This is an old revision of the document!


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

apt install bridge-utils

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

ubuntu_lxc_lxd.1507706563.txt.gz · Last modified: 2017/10/11 07:22 by admin