LXC container
This chapter is about containers and the administration tasks.
Create container
Creation debootstrap
Option -t debian
get build template from here /usr/share/lxc/templates
# lxc-create -n test1 -t debian -- -r bullseye debootstrap is /usr/sbin/debootstrap Checking cache download in /var/cache/lxc/debian/rootfs-bullseye-amd64 ... Downloading debian minimal ... I: Target architecture can be executed I: Retrieving InRelease I: Checking Release signature I: Valid Release signature (key id A4285295FC7B1A81600062A9605C66F00D6C9793) I: Retrieving Packages I: Validating Packages I: Resolving dependencies of required packages... I: Resolving dependencies of base packages... I: Checking component main on http://deb.debian.org/debian... I: Retrieving libacl1 2.2.53-10 I: Validating libacl1 2.2.53-10 [...] Creating SSH2 ED25519 key; this may take some time ... 256 SHA256:uApwt47pipdgvnBnFh8arnqahCC+BqNDT0DL1zBYloo root@darlene (ED25519) invoke-rc.d: could not determine current runlevel invoke-rc.d: policy-rc.d denied execution of start. Current default time zone: 'Etc/UTC' Local time is now: Wed Mar 16 15:06:22 UTC 2022. Universal Time is now: Wed Mar 16 15:06:22 UTC 2022.
Creation download
# lxc-create -t download -n test2 -- -d debian -r bullseye -a amd64 --keyserver hkp://keyserver.ubuntu.com Setting up the GPG keyring Downloading the image index Downloading the rootfs Downloading the metadata The image cache is now ready Unpacking the rootfs --- You just created a Debian bullseye amd64 (20220316_05:25) container.
Start container
# lxc-start -n my-container -d
Use container
# lxc-info -n my-container Name: my-container State: RUNNING PID: 9972 CPU use: 1.14 seconds BlkIO use: 49.00 MiB
# lxc-ls -f NAME STATE IPV4 IPV6 AUTOSTART -------------------------------------------- my-container RUNNING - - NO
# lxc-attach -n my-container root@my-container:/#
Stop container
# lxc-stop -n my-container
Delete container
# lxc-destroy -n my-container
Return to LXC Debian