From 61e04d7cfea706acbd1a0a96a470b463e4510edb Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Thu, 27 Apr 2023 18:54:01 +0200 Subject: [PATCH] fix: improved readibility --- .vscode/settings.json | 2 ++ knowledge base/lxc.md | 61 ++++++++++++++++++++++--------------------- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 2112a87..6d5077c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,6 +13,7 @@ "btrfs", "byod", "cereda", + "cfengine", "chattr", "chezmoi", "chsh", @@ -55,6 +56,7 @@ "markdownlint", "mktemp", "mpiexec", + "netcat", "nmap", "nvme", "ocsp", diff --git a/knowledge base/lxc.md b/knowledge base/lxc.md index 89467be..591a4cd 100644 --- a/knowledge base/lxc.md +++ b/knowledge base/lxc.md @@ -3,50 +3,51 @@ ## TL;DR ```sh -# install lxc -apt-get install lxc -snap install lxd +# Install the LXC runtime +apt-get install 'lxc' +snap install 'lxd' -# list available templates -ls /usr/share/lxc/templates +# List available templates. +ls '/usr/share/lxc/templates' -# create a new container -# use the download template to choose from a list of distribution -lxc-create --name container-name --template download +# Create new containers. +# Use the 'download' template to choose from a list of distribution +lxc-create -n 'pi-hole' --template 'download' -# start a container -lxc-start --name container-name -lxc-start --name container-name --foreground -lxc-start --name container-name --daemon --define CONFIGVAR=VALUE +# Start containers. +lxc-start -n 'pi-hole' +lxc-start -n 'git-server' --foreground +lxc-start -n 'cfengine' --daemon --define 'CONFIGVAR=VALUE' -# stop a container -lxc-stop --name container-name -lxc-stop --name container-name --kill +# Stop containers. +lxc-stop -n 'mariadb' +lxc-stop -n 'netcat' --kill -# destroy a container -# needs the container to be stopped -lxc-destroy --name container-name +# Destroy containers. +# Requires the container to be already stopped. +lxc-destroy -n 'netcat' -# get a container status -lxc-info --name container-name +# Get containers' status. +lxc-info -n 'pi-hole' -# get the status of all containers +# Get the status of all containers. lxc-ls --fancy -# get a shell inside a container -lxc-attach --name container-name +# Get a shell inside containers. +lxc-attach -n 'git-server' -# get config options on man -man 5 lxc.container.conf -man lxc.container.conf.5 -man lxc.container.conf(5) +# Get configuration options from `man` +man 5 'lxc.container.conf' +man 'lxc.container.conf.5' +man 'lxc.container.conf(5)' ``` -## Create new containers as unprivileged user +## Create new containers as an unprivileged user ```sh -# allow user vagrant to create up to 10 veth devices connected to the lxcbr0 bridge -echo "vagrant veth lxcbr0 10" | sudo tee -a /etc/lxc/lxc-usernet +# Allow user 'vagrant' to create up to 10 'veth' devices connected to the +# 'lxcbr0' bridge. +echo "vagrant veth lxcbr0 10" | sudo tee -a '/etc/lxc/lxc-usernet' ``` ## Further readings