nixos-container
manages lightweight NixOS containers using Linux namespaces
TLDR
List running containers
SYNOPSIS
nixos-container command [options] [containername_]
DESCRIPTION
nixos-container manages lightweight NixOS containers using Linux namespaces (systemd-nspawn). Each container runs a minimal NixOS system with its own configuration, services, and network namespace.
Containers are configured using standard NixOS configuration files, enabling declarative management of containerized services. The container shares the host's kernel but has an isolated filesystem, process tree, and optionally network.
Configuration files are stored in /var/lib/container/<name>/etc/nixos/ and can be edited directly before running update to apply changes.
PARAMETERS
list
List all containerscreate _name_
Create a new containerstart _name_
Start a stopped containerstop _name_
Stop a running containerterminate _name_
Forcefully terminate a containerdestroy _name_
Remove a container and its configurationstatus _name_
Show container statusrun _name_ -- _command_
Execute a command inside the containerroot-login _name_
Open an interactive root shell in the containerupdate _name_
Rebuild container after configuration changes--config-file _path_
Nix configuration file for the container
CAVEATS
Requires root privileges. NixOS-specific; not available on other distributions. Containers share the host kernel, so kernel modules and versions are inherited. Network configuration requires explicit setup for external connectivity.
SEE ALSO
nixos-rebuild(8), systemd-nspawn(1), machinectl(1)
