From 3f69286ef4b15161febb4a4bae085fb4c2c83bbf Mon Sep 17 00:00:00 2001 From: Jasper Ras Date: Sat, 29 Mar 2025 11:32:44 +0100 Subject: vault backup: 2025-03-29 11:32:44 --- NixOS - Imperative container management.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 NixOS - Imperative container management.md (limited to 'NixOS - Imperative container management.md') diff --git a/NixOS - Imperative container management.md b/NixOS - Imperative container management.md new file mode 100644 index 0000000..7099e6e --- /dev/null +++ b/NixOS - Imperative container management.md @@ -0,0 +1,25 @@ +As root using `nixos-container`. + +Container root: `/var/lib/nixos-containers +Config file: `/etc/nixos-containers` + +Create with: `nixos-container create foo`. +During create we can pass `--config` or `--config-file`. +By default it gets an address in the range `10.233.0.0/16` but this can be overridden using `--host-address` and `--local-address`. + +It needs to be started explicitly `nixos-container start foo`. +The container runs as a systemd unit on the host `systemctl status container@foo`. + +Login can be done as root using `nixos-container root-login foo` whilst regular authenticated login is also possible with `login`. + +Arbitrary command execution: `nixos-container run foo -- whoami` + +Build and activate new configuration: `nixos-container update foo`, this reads `/var/lib/nixos-containers/foo/etc/nixos/configuration.nix`. +^ Also allows passing in `--config` from the CLI, this overrides its `configuration.nix`. + +Start/stop using systemd or `nixos-container start|stop`. +Destroy completely using: `nixos-container destroy foo`. + +--- +[[NixOS - Containers]] +[[NixOS - Advantage of imperative container management]] \ No newline at end of file -- cgit v1.2.3