From 1271ce3c6162bdf8a6e450e2d9c10d3bdeb1a389 Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Mon, 16 Oct 2023 15:13:12 +0200 Subject: [PATCH] fix: docker prune volumes --- modules/docker.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/docker.nix b/modules/docker.nix index 89e8cb7..8d7e470 100644 --- a/modules/docker.nix +++ b/modules/docker.nix @@ -28,6 +28,7 @@ # }; # Run `docker system prune -f ${autoPrune.flags}` every week. + # This creates `docker-prune.service` and `docker-prune.timer`. autoPrune.enable = true; autoPrune.dates = "weekly"; # https://docs.docker.com/engine/reference/commandline/system_prune/#options @@ -54,9 +55,17 @@ script = '' ${pkgs.docker}/bin/docker system prune -f --all --volumes ''; + + # Run weekly after `docker-prune.service` has finished. + # Reason: Only one `docker system prune` command can be run at a time. + startAt = "weekly"; - after = [ "docker.service" ]; + # Start the specified units when this unit is started, + # and stop this unit when the specified units are stopped or fail. requires = [ "docker.service" ]; + # If the specified units are started at the same time as this unit, + # delay this unit until they have started. + after = [ "docker.service" "docker-prune.service" ]; }; # Monitor unhealthy Docker containers.