LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

nixos-container

manages lightweight NixOS containers using Linux namespaces

TLDR

List the containers that exist
$ sudo nixos-container list
copy
Create one from an inline configuration
$ sudo nixos-container create [name] --config '{ services.openssh.enable = true; }'
copy
Create one from a configuration file
$ sudo nixos-container create [name] --config-file [path/to/configuration.nix]
copy
Give it fixed private addresses on both sides of the link
$ sudo nixos-container create [name] --local-address [10.233.4.2] --host-address [10.233.4.1]
copy
Have it start automatically at boot
$ sudo nixos-container create [name] --auto-start
copy
Start a container
$ sudo nixos-container start [name]
copy
Check whether it is running
$ sudo nixos-container status [name]
copy
Find its IP address
$ sudo nixos-container show-ip [name]
copy
Open a root shell inside it
$ sudo nixos-container root-login [name]
copy
Run one command inside it
$ sudo nixos-container run [name] -- [command]
copy
Rebuild it after editing its configuration
$ sudo nixos-container update [name]
copy
Stop it
$ sudo nixos-container stop [name]
copy
Kill it without a clean shutdown
$ sudo nixos-container terminate [name]
copy
Delete it along with its filesystem
$ sudo nixos-container destroy [name]
copy

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 containers
create _name_
Create a new container
start _name_
Start a stopped container
stop _name_
Stop a running container
terminate _name_
Forcefully terminate a container
destroy _name_
Remove a container and its configuration
status _name_
Show container status
run _name_ -- _command_
Execute a command inside the container
root-login _name_
Open an interactive root shell in the container
update _name_
Rebuild container after configuration changes
--config-file _path_
Nix configuration file for the container

INSTALL

nix profile install nixpkgs#nixos-container
copy

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

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid