Section: systemd-nspawn (1)
:systemd-nspawn [OPTIONS...] [COMMAND [ARGS...]]
:systemd-nspawn -b [OPTIONS...] [ARGS...]
systemd-nspawn limits access to various kernel interfaces in the container to read-only, such as /sys, /proc/sys or /sys/fs/selinux. Network interfaces and the system clock may not be changed from within the container. Device nodes may not be created. The host system cannot be rebooted and kernel modules may not be loaded from within the container.
Note that even though these security precautions are taken systemd-nspawn is not suitable for secure container setups. Many of the security features may be circumvented and are hence primarily useful to avoid accidental changes to the host system from the container. The intended use of this program is debugging and testing as well as building of packages, distributions and software involved with boot and systems management.
Note that systemd-nspawn will mount file systems private to the container to /dev, /run and similar. These will not be visible outside of the container, and their contents will be lost when the container exits.
Note that running two systemd-nspawn containers from the same directory tree will not make processes in them see each other. The PID namespace separation of the two containers is complete and the containers will share very few runtime objects except for the underlying file system. Use machinectl?(1)'s login command to request an additional login prompt in a running container.
systemd-nspawn implements the m[blue]Container Interfacem specification.
As a safety check systemd-nspawn will verify the existence of /usr/lib/os-release or /etc/os-release in the container tree before starting the container (see os-release?(5)). It might be necessary to add this file to the container tree manually if the OS of the container is too old to contain this file out-of-the-box.
If option -b is specified, the arguments are used as arguments for the init binary. Otherwise, COMMAND specifies the program to launch in the container, and the remaining arguments are used as arguments for this program. If -b is not used and no arguments are specifed, a shell is launched in the container.
The following options are understood:
# yum -y --releasever=19 --nogpg --installroot=/srv/mycontainer --disablerepo='*' --enablerepo=fedora install systemd passwd yum fedora-release vim-minimal # systemd-nspawn -bD /srv/mycontainer
# debootstrap --arch=amd64 unstable ~/debian-tree/ # systemd-nspawn -D ~/debian-tree/
# pacstrap -c -d ~/arch-tree/ base # systemd-nspawn -bD ~/arch-tree/
# btrfs subvolume snapshot / /.tmp # systemd-nspawn --private-network -D /.tmp -b
# chcon system_u:object_r:svirt_sandbox_file_t:s0:c0,c1 -R /srv/container # systemd-nspawn -L system_u:object_r:svirt_sandbox_file_t:s0:c0,c1 -Z system_u:system_r:svirt_lxc_net_t:s0:c0,c1 -D /srv/container /bin/sh
Tutoriais de Tecnologia Web