X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/19e911cb27b7b413829a7cbb38aad5a59db171c5..2a9e93bd39ad46954630a0d1e43566e7ccb2aa81:/cookbooks/docker/recipes/default.rb diff --git a/cookbooks/docker/recipes/default.rb b/cookbooks/docker/recipes/default.rb index 1dfe9adde..aa4aa34f0 100644 --- a/cookbooks/docker/recipes/default.rb +++ b/cookbooks/docker/recipes/default.rb @@ -17,12 +17,13 @@ # limitations under the License. # -include_recipe "apt" +include_recipe "apt::docker" package %w[ docker-ce docker-ce-cli containerd.io + docker-compose-plugin ] directory "/etc/docker" do @@ -42,3 +43,25 @@ service "docker" do action [:enable, :start] subscribes :restart, "template[/etc/docker/daemon.json]" end + +systemd_service "docker-system-prune" do + description "Cleanup up unused docker images and containers" + after ["docker.service"] + wants ["docker.service"] + user "root" + exec_start "/usr/bin/docker system prune --all --force" + sandbox :enable_network => true + memory_deny_write_execute false + restrict_address_families "AF_UNIX" +end + +systemd_timer "docker-system-prune" do + description "Cleanup up unused docker images and containers" + on_boot_sec "2h" + on_unit_active_sec "7d" + randomized_delay_sec "4h" +end + +service "docker-system-prune.timer" do + action [:enable, :start] +end