diff options
author | Jasper Ras <jras@hostnet.nl> | 2025-03-29 11:32:44 +0100 |
---|---|---|
committer | Jasper Ras <jras@hostnet.nl> | 2025-03-29 11:32:44 +0100 |
commit | 3f69286ef4b15161febb4a4bae085fb4c2c83bbf (patch) | |
tree | 10679f5b5e712242939a1eba233241fabfec1927 /NixOS - Imperative container management.md | |
parent | fe63b70cae6e68adea7b25ad2f04ffc834b4e75f (diff) |
vault backup: 2025-03-29 11:32:44
Diffstat (limited to 'NixOS - Imperative container management.md')
-rw-r--r-- | NixOS - Imperative container management.md | 25 |
1 files changed, 25 insertions, 0 deletions
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 |