Skip to content

Commit

Permalink
docker_cleanup: limit default pruning to images only and make it conf…
Browse files Browse the repository at this point in the history
…igurable (#299)

The problem is that `docker system prune` will cleanup:
       - all stopped containers
        - all networks not used by at least one container
        - all dangling images
        - unused build cache
        
I don't think that we want it to cleanup stopped docker containers by
default. This affected me on certain machines.

Having the default policy just to prune images, should be enough.
  • Loading branch information
skylenet authored Dec 12, 2024
1 parent e5fdf85 commit 46e27a2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions roles/docker_cleanup/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
docker_cleanup_cron_name: docker-clean-up
docker_cleanup_schedule: ["0", "0", "*", "*", "*"] # Cron format https://en.wikipedia.org/wiki/Cron
# Defaults to 00h00 every day
docker_cleanup_command: "docker image prune -f"
2 changes: 1 addition & 1 deletion roles/docker_cleanup/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
day: "{{ docker_cleanup_schedule[2] }}"
month: "{{ docker_cleanup_schedule[3] }}"
weekday: "{{ docker_cleanup_schedule[4] }}"
job: "docker system prune -f &>/dev/null"
job: "{{ docker_cleanup_command }}"

0 comments on commit 46e27a2

Please sign in to comment.