diff --git a/nixos/modules/virtualisation/docker.nix b/nixos/modules/virtualisation/docker.nix index 099d60423f00..26b9e9cbaf73 100644 --- a/nixos/modules/virtualisation/docker.nix +++ b/nixos/modules/virtualisation/docker.nix @@ -157,6 +157,14 @@ in Whether to periodically prune Docker resources. If enabled, a systemd timer will run `docker system prune -f` as specified by the `dates` option. + + NOTE: by default this does not prune volumes. Anonymous volumes + can be pruned by passing "--volumes" to [autoPrune.flags](#opt-virtualisation.docker.autoPrune.flags). + + To prune all volumes (not just anonymous ones) [`autoPrune.allVolumes.enable`](#opt-virtualisation.docker.autoPrune.allVolumes.enable) + must be used. + + See [upstream documentation](https://docs.docker.com/reference/cli/docker/system/prune/#description) for further information. ''; }; @@ -206,6 +214,28 @@ in system was powered down. ''; }; + + allVolumes = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to periodically prune all Docker volumes when auto pruning other docker resources + by running {command}`docker volume prune --force --all` + + To prune only anonymous volumes, instead pass `--volumes` to `autoPrune.flags` + ''; + }; + + flags = mkOption { + type = types.listOf types.str; + default = [ ]; + example = [ "--filter=label=