Utworzenie kontenera LXC - Nginx
lxc-create -n srv-nginx -t download -- -d debian -r trixie -a amd64-n : nazwa kontenera
-t : oparty na systemie debiana (można wybrac inne dystrybucje)
powiązanie z mostkiem sieciowym
nano /var/lib/lxc/srv-nginx/config# Template used to create this container: /usr/share/lxc/templates/lxc-download
# Parameters passed to the template: -d debian -r trixie -a amd64
# For additional config options, please look at lxc.container.conf(5)
# Uncomment the following line to support nesting containers:
#lxc.include = /usr/share/lxc/config/nesting.conf
# (Be aware this has security implications)
# Distribution configuration
lxc.include = /usr/share/lxc/config/common.conf
lxc.arch = linux64
# Container specific configuration
lxc.apparmor.profile = generated
lxc.apparmor.allow_nesting = 1
lxc.rootfs.path = dir:/var/lib/lxc/srv-nginx/rootfs
lxc.uts.name = nginx
# Network configuration
lxc.net.0.type = veth
lxc.net.0.link = br0
lxc.net.0.flags = up
#Auto start
lxc.start.auto = 1
lxc.start.order = 3
lxc.start.delay = 5
# Limit pamięci RAM (np. 1 GB)
lxc.cgroup2.memory.max = 2G
lxc.cgroup2.memory.high = 1843M
# Limit pamięci SWAP (np. 512 MB)
lxc.cgroup2.memory.swap.max = 0
# Przypisanie rdzeni procesora (rdzeń 0 )
lxc.cgroup2.cpuset.cpus = 2-3
#Montowanie katalogów domowych userów
#lxc.mount.entry = /home/LO home/LO none bind,create=dir 0 0
#lxc.mount.entry = /var/www/html var/www/html none bind,create=dir 0 0Ustawienia karty sieciowej dla kontenera
nano /var/lib/lxc/srv-nginx/rootfs/etc/systemd/network/10-eth0.network[Match]
Name=eth0
[Network]
Address=192.168.10.202/24
Gateway=192.168.10.200
DNS=192.168.10.201
DNS=1.1.1.1
DNS=8.8.8.8lxc-stop -n srv-nginx
lxc-start -n srv-nginx
lxc-attach -n srv-nginxSprawdzenie
free -m
nproc
lxc-attach -n srv-nginx-- ping -c 3 1.1.1.1
ping -c 3 google.com