Files
tldr/pages.zh/linux/systemd-nspawn.md

20 lines
701 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# systemd-nspawn
> 在轻量级容器中启动命令或操作系统。
> 更多信息:<https://www.freedesktop.org/software/systemd/man/latest/systemd-nspawn.html>。
- 在容器中运行命令:
`systemd-nspawn --directory {{path/to/container_root}}`
- 在容器中运行完整的基于 Linux 的操作系统:
`systemd-nspawn --boot --directory {{path/to/container_root}}`
- 使用存根 init 进程在容器中将指定命令作为 PID 2 运行(而不是 PID 1
`systemd-nspawn --directory {{path/to/container_root}} --as-pid2`
- 指定机器名称和主机名:
`systemd-nspawn --machine={{container_name}} --hostname={{container_host}} --directory {{path/to/container_root}}`