-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.nix
82 lines (74 loc) · 1.84 KB
/
docker.nix
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{
config,
lib,
pkgs,
...
}:
{
environment.etc."docker/compose.yaml" = {
mode = "0440";
text = ''
# https://docs.docker.com/compose/compose-file/
---
networks:
general:
driver_opts:
com.docker.network.bridge.name: br-d4r-general
ipam:
config:
- subnet: 172.20.0.0/16
services:
portainer:
container_name: portainer
image: portainer/portainer-ee
networks:
general:
ipv4_address: 172.20.0.10
ports:
- "127.0.0.1:9000:9000/tcp"
restart: always
volumes:
- "portainer:/data:rw"
- "/var/run/docker.sock:/var/run/docker.sock:ro"
watchtower:
container_name: watchtower
environment:
TZ: "Europe/London"
WATCHTOWER_CLEANUP: "true"
WATCHTOWER_POLL_INTERVAL: "3600"
image: containrrr/watchtower
networks:
general:
ipv4_address: 172.20.0.20
restart: always
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
volumes:
portainer:
'';
};
system.activationScripts.docker-amd64 = if pkgs.stdenv.hostPlatform.system != "x86_64-linux" then ''
if [[ ''${NIXOS_ACTION} = "switch" ]]
then
${pkgs.docker}/bin/docker run --privileged --rm tonistiigi/binfmt --install amd64
fi
'' else "";
systemd.services.docker-compose = {
after = [
"docker.service"
"docker.socket"
];
path = [
pkgs.docker-compose
];
script = "docker-compose --file /etc/docker/compose.yaml up";
wantedBy = [
"multi-user.target"
];
};
virtualisation.docker = {
autoPrune.dates = "daily";
autoPrune.enable = true;
enable = true;
};
}