0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

CentOS8 に systemd-nspawn用 CentOS8 コンテナを作成する

Last updated at Posted at 2020-07-16
NEW_MACHINE='centos8'
yum --releasever=8 \
    --nogpg \
    --installroot=/var/lib/machines/${NEW_MACHINE} \
    --disablerepo='*' \
    --enablerepo=BaseOS \
    install systemd passwd yum sudo

sudo systemd-nspawn -D /var/lib/machines/${NEW_MACHINE}
passwd
useradd -m -r user
passwd user
usermod -G wheel user
exit

# 起動確認
sudo systemd-nspawn -bD /var/lib/machines/${NEW_MACHINE}
Ctrl+]
Ctrl+]
Ctrl+]

# unit file 
systemctl enable systemd-nspawn@${NEW_MACHINE}.service

(echo '[Service]'
 echo 'ExecStart='
 echo 'ExecStart=/usr/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=try-guest --machine=%I'
) | SYSTEMD_EDITOR=tee systemctl edit systemd-nspawn@${NEW_MACHINE}.service

cat /usr/lib/systemd/system/systemd-nspawn@.service
cat /etc/systemd/system/machines.target.wants/systemd-nspawn@${NEW_MACHINE}.service
cat /etc/systemd/system/systemd-nspawn@${NEW_MACHINE}.service.d/override.conf

machinectl start ${NEW_MACHINE}
machinectl login ${NEW_MACHINE}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?