fix: improved readibility

This commit is contained in:
Michele Cereda
2023-04-27 18:54:01 +02:00
parent 46488fd534
commit 61e04d7cfe
2 changed files with 33 additions and 30 deletions

View File

@@ -13,6 +13,7 @@
"btrfs",
"byod",
"cereda",
"cfengine",
"chattr",
"chezmoi",
"chsh",
@@ -55,6 +56,7 @@
"markdownlint",
"mktemp",
"mpiexec",
"netcat",
"nmap",
"nvme",
"ocsp",

View File

@@ -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