modules(pihole-container): pre-start cleanup old pihole containers
If container cleanup fails when the machine halts it is necessary to cleanup the old container before the new one starts or it will fail.
This commit is contained in:
parent
0c360c6f64
commit
5fb27f33b3
1 changed files with 3 additions and 2 deletions
|
@ -347,6 +347,7 @@ in rec {
|
||||||
ExecStartPre = mkIf cfg.hostConfig.persistVolumes [
|
ExecStartPre = mkIf cfg.hostConfig.persistVolumes [
|
||||||
"${pkgs.coreutils}/bin/mkdir -p ${cfg.hostConfig.volumesPath}/etc-pihole"
|
"${pkgs.coreutils}/bin/mkdir -p ${cfg.hostConfig.volumesPath}/etc-pihole"
|
||||||
"${pkgs.coreutils}/bin/mkdir -p ${cfg.hostConfig.volumesPath}/etc-dnsmasq.d"
|
"${pkgs.coreutils}/bin/mkdir -p ${cfg.hostConfig.volumesPath}/etc-dnsmasq.d"
|
||||||
|
''${pkgs.podman}/bin/podman rm --ignore "${cfg.hostConfig.containerName}"''
|
||||||
];
|
];
|
||||||
|
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
|
@ -369,12 +370,12 @@ in rec {
|
||||||
} \
|
} \
|
||||||
docker-archive:${piholeFlake.packages.${pkgs.system}.piholeImage}
|
docker-archive:${piholeFlake.packages.${pkgs.system}.piholeImage}
|
||||||
'';
|
'';
|
||||||
#TODO check that user can control podman & has subuidmap/subgidmap set
|
|
||||||
User = "${cfg.hostConfig.user}";
|
User = "${cfg.hostConfig.user}";
|
||||||
};
|
};
|
||||||
|
|
||||||
postStop = ''
|
postStop = ''
|
||||||
while ${pkgs.podman}/bin/podman container exists ${cfg.hostConfig.containerName}; do
|
while ${pkgs.podman}/bin/podman container exists "${cfg.hostConfig.containerName}"; do
|
||||||
${pkgs.coreutils-full}/bin/sleep 2;
|
${pkgs.coreutils-full}/bin/sleep 2;
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Add table
Reference in a new issue