OS Manuals

/usr/bin/systemd-nspawn

systemd container tools

From systemd-container 262.2-r1 (os), captured 2026-11-05 by running systemd-nspawn --help (exit 0). permalink

> systemd-nspawn [OPTION…] [PATH] [ARGUMENTS…]

Spawn a command or OS in a lightweight container.

Options:
  -h --help                                     Show this help
     --version                                  Show package version
  -q --quiet                                    Do not show status information
     --no-pager                                 Do not start a pager
     --settings=BOOLEAN                         Load additional settings from .nspawn file
     --cleanup                                  Clean up left-over mounts and underlying mount
                                                points used by the container
     --no-ask-password                          Do not prompt for password

Image:
  -D --directory=PATH                           Root directory for the container
     --template=PATH                            Initialize root directory from template directory,
                                                if missing
  -x --ephemeral                                Run container with snapshot of root directory, and
                                                remove it after exit
  -i --image=PATH                               Root file system disk image (or device node) for the
                                                container
     --image-policy=POLICY                      Specify disk image dissection policy
     --oci-bundle=PATH                          OCI bundle directory
     --read-only                                Mount the root directory read-only
     --volatile[=MODE]                          Run the system in volatile mode
     --root-hash=HASH                           Specify verity root hash for root disk image
     --root-hash-sig=SIG                        Specify pkcs7 signature of root hash for verity
     --verity-data=PATH                         Specify hash device for verity
     --pivot-root=PATH[:PATH]                   Pivot root to given directory in the container

Execution:
  -a --as-pid2                                  Maintain a stub init as PID1, invoke binary as PID2
  -b --boot                                     Boot up full system (i.e. invoke init)
     --chdir=PATH                               Set working directory in the container
  -E --setenv=NAME[=VALUE]                      Pass an environment variable to PID 1
  -u --uid=USER                                 Run the command under specified user or UID
     --kill-signal=SIGNAL                       Select signal to use for shutting down PID 1
     --notify-ready=BOOLEAN                     Receive notifications from the child init process
     --suppress-sync=BOOLEAN                    Suppress any form of disk data synchronization

System Identity:
  -M --machine=NAME                             Set the machine name for the container
     --hostname=NAME                            Override the hostname for the container
     --uuid=UUID                                Set a specific machine UUID for the container

Properties:
  -S --slice=SLICE                              Place the container in the specified slice
     --property=NAME=VALUE                      Set scope unit property
     --register=BOOLEAN                         Register container as machine
     --keep-unit                                Do not register a scope for the machine, reuse the
                                                service unit nspawn is running in

User Namespacing:
     --private-users[=MODE]                     Run within user namespace, configure UID/GID range
     --private-users-ownership=MODE             Adjust ('chown') or map ('map') OS tree ownership to
                                                private UID/GID range
     --private-users-delegate=N                 Delegate N additional 64K UID/GID ranges for use by
                                                nested containers
  -U                                            Equivalent to --private-users=pick and
                                                --private-users-ownership=auto

Networking:
     --private-network                          Disable network in container
     --network-interface=HOSTIF[:CONTAINERIF]   Assign an existing network interface to the
                                                container
     --network-macvlan=HOSTIF[:CONTAINERIF]     Create a macvlan network interface based on an
                                                existing network interface to the container
     --network-ipvlan=HOSTIF[:CONTAINERIF]      Create an ipvlan network interface based on an
                                                existing network interface to the container
  -n --network-veth                             Add a virtual Ethernet connection between host and
                                                container
     --network-veth-extra=HOSTIF[:CONTAINERIF]  Add an additional virtual Ethernet link between host
                                                and container
     --network-bridge=INTERFACE                 Add a virtual Ethernet connection to the container
                                                and attach it to an existing bridge on the host
     --network-zone=NAME                        Similar, but attach the new interface to an
                                                automatically managed bridge interface
     --network-namespace-path=PATH              Set network namespace to the one represented by the
                                                specified kernel namespace file node
  -p --port=[PROTOCOL:]HOSTPORT[:CONTAINERPORT] Expose a container IP port on the host

Security:
     --capability=CAP                           In addition to the default, retain specified
                                                capability
     --drop-capability=CAP                      Drop the specified capability from the default set
     --ambient-capability=CAP                   Sets the specified capability for the started
                                                process
     --no-new-privileges=BOOL                   Set PR_SET_NO_NEW_PRIVS flag for container payload
     --system-call-filter=LIST|~LIST            Permit/prohibit specific system calls
     --restrict-address-families=LIST           Restrict socket address families to the given
                                                allowlist
  -Z --selinux-context=SECLABEL                 Set the SELinux security context to be used by
                                                processes in the container
  -L --selinux-apifs-context=SECLABEL           Set the SELinux security context to be used by
                                                API/tmpfs file systems in the container

Resources:
     --rlimit=NAME=LIMIT                        Set a resource limit for the payload
     --oom-score-adjust=VALUE                   Adjust the OOM score value for the payload
     --cpu-affinity=CPUS                        Adjust the CPU affinity of the container
     --personality=ARCH                         Pick personality for this container

Integration:
     --resolv-conf=MODE                         Select mode of /etc/resolv.conf initialization
     --timezone=MODE                            Select mode of /etc/localtime initialization
     --link-journal=MODE                        Link up guest journal, one of no, auto, guest, host,
                                                try-guest, try-host
  -j                                            Equivalent to --link-journal=try-guest
     --forward-journal=FILE|DIR                 Forward the container's journal to the host
     --forward-journal-max-use=BYTES            Maximum disk space for forwarded journal
     --forward-journal-keep-free=BYTES          Minimum disk space to keep free
     --forward-journal-max-file-size=BYTES      Maximum size of individual journal files
     --forward-journal-max-files=N              Maximum number of journal files to keep

Mounts:
     --bind=PATH[:PATH[:OPTIONS]]               Bind mount a file or directory from the host into
                                                the container
     --bind-ro=PATH[:PATH[:OPTIONS]]            Similar, but creates a read-only bind mount
     --inaccessible=PATH                        Over-mount file node with inaccessible node to mask
                                                it
     --tmpfs=PATH:[OPTIONS]                     Mount an empty tmpfs to the specified directory
     --overlay=PATH[:PATH...]:PATH              Create an overlay mount from the host to the
                                                container
     --overlay-ro=PATH[:PATH...]:PATH           Similar, but creates a read-only overlay mount
     --bind-user=NAME                           Bind user from host to container
     --bind-user-shell=BOOL|PATH                Configure the shell to use for --bind-user= users
     --bind-user-group=GROUP                    Add an auxiliary group to --bind-user= users

Input/Output:
     --console=MODE                             Select how stdin/stdout/stderr and /dev/console are
                                                set up for the container
  -P --pipe                                     Equivalent to --console=pipe
     --background=COLOR                         Set ANSI color for background

Credentials:
     --set-credential=ID:VALUE                  Pass a credential with literal value to container
     --load-credential=ID:PATH                  Load credential to pass to container from file or
                                                AF_UNIX stream socket

Other:
     --user[=NAME]                              Run in the user service manager scope
     --system                                   Run in the system service manager scope

See the systemd-nspawn(1) man page for details.
Options (84)
OptionDescriptionSource
-h --helpShow this helphelp
--versionShow package versionhelp
-q --quietDo not show status informationhelp
--no-pagerDo not start a pagerhelp
--settings BOOLEANLoad additional settings from .nspawn filehelp
--cleanupClean up left-over mounts and underlying mount points used by the containerhelp
--no-ask-passwordDo not prompt for passwordhelp
-D --directory=PATHRoot directory for the containerhelp
--template PATHInitialize root directory from template directory, if missinghelp
-x --ephemeralRun container with snapshot of root directory, and remove it after exithelp
-i --image=PATHRoot file system disk image (or device node) for the containerhelp
--image-policy POLICYSpecify disk image dissection policyhelp
--oci-bundle PATHOCI bundle directoryhelp
--read-onlyMount the root directory read-onlyhelp
--volatile MODERun the system in volatile modehelp
--root-hash HASHSpecify verity root hash for root disk imagehelp
--root-hash-sig SIGSpecify pkcs7 signature of root hash for verityhelp
--verity-data PATHSpecify hash device for verityhelp
--pivot-root PATH[:PATHPivot root to given directory in the containerhelp
-a --as-pid2Maintain a stub init as PID1, invoke binary as PID2help
-b --bootBoot up full system (i.e. invoke init)help
--chdir PATHSet working directory in the containerhelp
-E --setenv=NAME[=VALUEPass an environment variable to PID 1help
-u --uid=USERRun the command under specified user or UIDhelp
--kill-signal SIGNALSelect signal to use for shutting down PID 1help
--notify-ready BOOLEANReceive notifications from the child init processhelp
--suppress-sync BOOLEANSuppress any form of disk data synchronizationhelp
-M --machine=NAMESet the machine name for the containerhelp
--hostname NAMEOverride the hostname for the containerhelp
--uuid UUIDSet a specific machine UUID for the containerhelp
-S --slice=SLICEPlace the container in the specified slicehelp
--property NAME=VALUESet scope unit propertyhelp
--register BOOLEANRegister container as machinehelp
--keep-unitDo not register a scope for the machine, reuse the service unit nspawn is running inhelp
--private-users MODERun within user namespace, configure UID/GID rangehelp
--private-users-ownership MODEAdjust ('chown') or map ('map') OS tree ownership to private UID/GID rangehelp
--private-users-delegate NDelegate N additional 64K UID/GID ranges for use by nested containershelp
-UEquivalent to --private-users=pick andhelp
--private-networkDisable network in containerhelp
--network-interface HOSTIF[:CONTAINERIFAssign an existing network interface to the containerhelp
--network-macvlan HOSTIF[:CONTAINERIFCreate a macvlan network interface based on an existing network interface to the containerhelp
--network-ipvlan HOSTIF[:CONTAINERIFCreate an ipvlan network interface based on an existing network interface to the containerhelp
-n --network-vethAdd a virtual Ethernet connection between host and containerhelp
--network-veth-extra HOSTIF[:CONTAINERIFAdd an additional virtual Ethernet link between host and containerhelp
--network-bridge INTERFACEAdd a virtual Ethernet connection to the container and attach it to an existing bridge on the hosthelp
--network-zone NAMESimilar, but attach the new interface to an automatically managed bridge interfacehelp
--network-namespace-path PATHSet network namespace to the one represented by the specified kernel namespace file nodehelp
--capability CAPIn addition to the default, retain specified capabilityhelp
--drop-capability CAPDrop the specified capability from the default sethelp
--ambient-capability CAPSets the specified capability for the started processhelp
--no-new-privileges BOOLSet PR_SET_NO_NEW_PRIVS flag for container payloadhelp
--system-call-filter LIST|~LISTPermit/prohibit specific system callshelp
--restrict-address-families LISTRestrict socket address families to the given allowlisthelp
-Z --selinux-context=SECLABELSet the SELinux security context to be used by processes in the containerhelp
-L --selinux-apifs-context=SECLABELSet the SELinux security context to be used by API/tmpfs file systems in the containerhelp
--rlimit NAME=LIMITSet a resource limit for the payloadhelp
--oom-score-adjust VALUEAdjust the OOM score value for the payloadhelp
--cpu-affinity CPUSAdjust the CPU affinity of the containerhelp
--personality ARCHPick personality for this containerhelp
--resolv-conf MODESelect mode of /etc/resolv.conf initializationhelp
--timezone MODESelect mode of /etc/localtime initializationhelp
--link-journal MODELink up guest journal, one of no, auto, guest, host, try-guest, try-hosthelp
-jEquivalent to --link-journal=try-guesthelp
--forward-journal FILE|DIRForward the container's journal to the hosthelp
--forward-journal-max-use BYTESMaximum disk space for forwarded journalhelp
--forward-journal-keep-free BYTESMinimum disk space to keep freehelp
--forward-journal-max-file-size BYTESMaximum size of individual journal fileshelp
--forward-journal-max-files NMaximum number of journal files to keephelp
--bind PATH[:PATH[:OPTIONSBind mount a file or directory from the host into the containerhelp
--bind-ro PATH[:PATH[:OPTIONSSimilar, but creates a read-only bind mounthelp
--inaccessible PATHOver-mount file node with inaccessible node to mask ithelp
--tmpfs PATH:[OPTIONSMount an empty tmpfs to the specified directoryhelp
--overlay PATH[:PATH...]:PATHCreate an overlay mount from the host to the containerhelp
--overlay-ro PATH[:PATH...]:PATHSimilar, but creates a read-only overlay mounthelp
--bind-user NAMEBind user from host to containerhelp
--bind-user-shell BOOL|PATHConfigure the shell to use for --bind-user= usershelp
--bind-user-group GROUPAdd an auxiliary group to --bind-user= usershelp
--console MODESelect how stdin/stdout/stderr and /dev/console are set up for the containerhelp
-P --pipeEquivalent to --console=pipehelp
--background COLORSet ANSI color for backgroundhelp
--set-credential ID:VALUEPass a credential with literal value to containerhelp
--load-credential ID:PATHLoad credential to pass to container from file or AF_UNIX stream sockethelp
--user NAMERun in the user service manager scopehelp
--systemRun in the system service manager scopehelp

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.