sudo debootstrap --arch=amd64 \ SUITE \ TARGETDIR \ MIRROR
sudo debootstrap --arch=amd64 \ stretch \ /var/lib/container-example/example1 \ http://httpredir.debian.org/debian
sudo /usr/sbin/multistrap --arch amd64 \ -f multistrap.conf \ -d TARGETDIR
[General] bootstrap=NameOfSectionDefiningRepo aptsources=NameOfSectionDefiningRepo [NameOfSectionDefiningRepo] source=MIRROR suite=SUITE keyring=debian-archive-keyring ubuntu-archive-keyring packages= systemd udev kmod apt
sudo /usr/sbin/multistrap --arch amd64 \ -f multistrap.conf \ -d /var/lib/container-example/example2
chroot /var/lib/container-example/example2 \ dpkg --configure -a
✔
chroot /var/lib/container-example/example2 dpkg -l exit
chroot /var/lib/container-example/example1 perl -e 'print "hello world\n"' -- perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_COLLATE = "C", LANG = "en_AU.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). hello world exit
chroot /var/lib/container-example/example2 apt install less -- Reading package lists... Done [..omitted..] Need to get 126 kB of archives. After this operation, 284 kB of additional disk space will be used. Err:1 http://httpredir.debian.org/debian stretch/main amd64 less amd64 481-2.1 Temporary failure resolving 'httpredir.debian.org' E: Failed to fetch http://httpredir.debian.org/debian/pool/main/l/less/less_481-2.1_amd64.deb Temporary failure resolving 'httpredir.debian.org' E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing? exit
shred -fu TARGETDIR/etc/hostname shred -fu TARGETDIR/etc/machine-id shred -fu TARGETDIR/etc/ssh/*_key echo "nameserver 1.1.1.1" > TARGETDIR/etc/resolv.conf
echo root:hunter2 | sudo chpasswd -c SHA256 -R TARGETDIR chroot TARGETDIR systemctl enable systemd-networkd chroot TARGETDIR systemctl enable systemd-resolved echo "nameserver 127.0.0.53" > TARGETDIR/etc/resolv.conf
rm -rf TARGETDIR/usr/share/locale/* rm -rf TARGETDIR/usr/share/doc/* rm -rf TARGETDIR/lib/udev/hwdb.bin
echo realhostname >TARGETDIR/etc/hostname echo 127.0.1.1 realhostname >>TARGETDIR/etc/hosts chroot TARGETDIR dpkg-reconfigure openssh-server
sudo systemd-nspawn --boot --ephemeral \ --directory=/var/lib/container-example/example2
<domain type='lxc'> <name>newhost</name> <memory unit='KiB'>200000</memory> <os> <type arch='x86_64'>exe</type> <init>/sbin/init</init> </os> ...
virsh -c lxc:/// define newhost.xml
virsh start newhost
<domain type='lxc'> <name>newhost</name> <memory unit='KiB'>200000</memory> <os> <type arch='x86_64'>exe</type> <init>/sbin/init</init> </os> <devices> <emulator>/usr/lib/libvirt/libvirt_lxc</emulator> <filesystem type='mount' accessmode='mapped'> <source dir='/var/lib/container-example/newhost'/> <target dir='/'/> </filesystem> <interface type='network'> <source network='default'/> <guest dev='host0'/> </interface> <console type='pty'> <target type='lxc' port='0'/> </console> </devices> </domain>
apt install rpm yum HOME= rpm --root=/var/lib/container-example/centos \ --initdb mkdir -p /var/lib/container-example/centos/var/lib mv /var/lib/container-example/centos/.rpmdb \ /var/lib/container-example/centos/var/lib/rpm wget http://mirror.centos.org/centos/7/os/x86_64/Packages/centos-release-7-6.1810.2.el7.centos.x86_64.rpm rpm --root=/var/lib/container-example/centos \ -i --nodeps \ centos-release-7-6.1810.2.el7.centos.x86_64.rpm yum --installroot=/var/lib/container-example/centos \ install -y rpm-build yum --nogpgcheck