X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/7e5e5ba26f4a5b06fad5d1a1049df947e8a9cf00..41b4f8ccdff661e5463961da893ef91866e9f74c:/cookbooks/docker/recipes/default.rb?ds=inline diff --git a/cookbooks/docker/recipes/default.rb b/cookbooks/docker/recipes/default.rb index 80fd15b3f..6e98de4da 100644 --- a/cookbooks/docker/recipes/default.rb +++ b/cookbooks/docker/recipes/default.rb @@ -17,7 +17,7 @@ # limitations under the License. # -include_recipe "apt" +include_recipe "apt::docker" package %w[ docker-ce @@ -41,5 +41,26 @@ end service "docker" do action [:enable, :start] subscribes :restart, "template[/etc/docker/daemon.json]" - not_if { kitchen? } +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