Systemd-nspawn

From Asenjo
Jump to: navigation, search

create a systemd-nspawn centos 7 container in fedora (32 now)

create a cento7.repo file

[centos7-chroot-base]
name=CentOS-7-Base
baseurl=http://mirror.centos.org/centos/7/os/x86_64
gpgcheck=0

create chroot dir:

mkdir ~/centos7_chroot

install system to chroot dir:

$ sudo dnf -c centos7.repo --disablerepo=* --enablerepo centos7-chroot-base --installroot /home/$USER/centos_chroot/ groups install 'Minimal Install'

boot container:

$ sudo systemd-nspawn -D ~/centos_chroot/
Spawning container centoschroot on /home/natxo/centos_chroot.
Press ^] three times within 1s to kill container.
[root@centoschroot ~]# cat /etc/redhat-release 
CentOS Linux release 7.8.2003 (Core)