NSpawn
NSpawn¶
Better Chroot
Info¶
https://archive.is/RBAlJ
https://wiki.archlinux.org/title/Systemd-nspawn
Making a Container¶
Create Container:
debootstrap --arch=amd64 jessie /var/lib/machines/container1/
systemd-nspawn -D /var/lib/machines/container1/ --machine test_container
Configuring Network:
#Main Host
##Make Bridge
brctl addbr cont-bridge
ip a a [IP Address] dev cont-bridge
##Attach Bridge
systemd-nspawn -D /var/lib/machines/container1/ --machine test_container --network-bridge=cont-bridge -b
#
Setup Systemd Service:
[Unit]
Description=Test Container
[Service]
LimitNOFILE=100000
ExecStart=/usr/bin/systemd-nspawn --machine=test_container --directory=/var/lib/machines/container1/ -b --network-ipvlan=[network interface]
Restart=always
[Install]
Also=dbus.service
Container Administration¶
To print a list of containers in the system:
machinectl list
To view information on a container’s status:
machinectl status test_container
To log into a container:
machinectl login test_container
To restart a container:
machinectl reboot test_container
To turn off a container:
machinectl poweroff test_container