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.