summaryrefslogtreecommitdiff
path: root/NixOS - Declarative container management.md
blob: 6262a907ba876811882f2b751613e988aa3f56ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Specify containers in the host's `configuration.nix`.

```nix
{
	containers.foo = 
	{
		config = { config, pkgs ... }:
		{
			autoStart = true; # This will start the container automatically.
			privateNetwork = true;
			hostAddress = "192.168.100.10";
			localAddress = "192.168.100.11";
		}
	}
}
```

Running containers are updated in-place without rebooting.

Declarative containers share the host's networking namespace by default, see above example on how to give it its own network.

If the configuration is deleted from the host's config and the config is rebuilt the container will be disabled. This **does not** delete its root filesystem. To delete the root fs use the [[NixOS - Imperative container management]] method.

---
[[NixOS - Containers]]