From f4bf952f34ae9a7243e7c505271f38fc1ca012d0 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Thu, 2 May 2019 15:08:55 -0700 Subject: [PATCH] Prune docker images after docker-compose up This ensures that we cleanup images that are superceded and no longer necessary. We do this to avoid filling the disk with docker images. Note that we use the -f flag to avoid being prompted by docker image prune for confirmation. Change-Id: I8eb5bb97d8c66755e695498707220c9e6e7b2de0 --- playbooks/roles/gitea/tasks/main.yaml | 3 +++ playbooks/roles/haproxy/tasks/main.yaml | 3 +++ playbooks/roles/registry/tasks/main.yaml | 3 +++ playbooks/roles/zuul-preview/tasks/main.yaml | 3 +++ 4 files changed, 12 insertions(+) diff --git a/playbooks/roles/gitea/tasks/main.yaml b/playbooks/roles/gitea/tasks/main.yaml index 077f05df06..89b03d8812 100644 --- a/playbooks/roles/gitea/tasks/main.yaml +++ b/playbooks/roles/gitea/tasks/main.yaml @@ -45,6 +45,9 @@ shell: cmd: docker-compose up -d --timeout 60 chdir: /etc/gitea-docker/ +- name: Run docker prune to cleanup unneeded images + shell: + cmd: docker image prune -f - name: Check if root user exists uri: url: "https://localhost:3000/api/v1/users/root" diff --git a/playbooks/roles/haproxy/tasks/main.yaml b/playbooks/roles/haproxy/tasks/main.yaml index 77ea84acba..957ffd293a 100644 --- a/playbooks/roles/haproxy/tasks/main.yaml +++ b/playbooks/roles/haproxy/tasks/main.yaml @@ -28,3 +28,6 @@ shell: cmd: docker-compose up -d chdir: /etc/haproxy-docker/ +- name: Run docker prune to cleanup unneeded images + shell: + cmd: docker image prune -f diff --git a/playbooks/roles/registry/tasks/main.yaml b/playbooks/roles/registry/tasks/main.yaml index 39c092f2a2..4126e8dc52 100644 --- a/playbooks/roles/registry/tasks/main.yaml +++ b/playbooks/roles/registry/tasks/main.yaml @@ -49,6 +49,9 @@ shell: cmd: docker-compose up -d chdir: /etc/registry-docker/ +- name: Run docker prune to cleanup unneeded images + shell: + cmd: docker image prune -f - name: Install cron to garbage collect the registry daily cron: diff --git a/playbooks/roles/zuul-preview/tasks/main.yaml b/playbooks/roles/zuul-preview/tasks/main.yaml index 2dba22e8c0..9b3afc839a 100644 --- a/playbooks/roles/zuul-preview/tasks/main.yaml +++ b/playbooks/roles/zuul-preview/tasks/main.yaml @@ -15,3 +15,6 @@ shell: cmd: docker-compose up -d chdir: /etc/zuul-preview-docker/ +- name: Run docker prune to cleanup unneeded images + shell: + cmd: docker image prune -f