summaryrefslogtreecommitdiffstats
path: root/playbooks/common/openshift-cluster/upgrades/docker/nuke_images.sh
diff options
context:
space:
mode:
Diffstat (limited to 'playbooks/common/openshift-cluster/upgrades/docker/nuke_images.sh')
-rw-r--r--playbooks/common/openshift-cluster/upgrades/docker/nuke_images.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/playbooks/common/openshift-cluster/upgrades/docker/nuke_images.sh b/playbooks/common/openshift-cluster/upgrades/docker/nuke_images.sh
new file mode 100644
index 000000000..8635eab0d
--- /dev/null
+++ b/playbooks/common/openshift-cluster/upgrades/docker/nuke_images.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+# Stop any running containers
+running_container_ids=`docker ps -q`
+if test -n "$running_container_ids"
+then
+ docker stop $running_container_ids
+fi
+
+# Delete all containers
+container_ids=`docker ps -a -q`
+if test -n "$container_ids"
+then
+ docker rm -f -v $container_ids
+fi
+
+# Delete all images (forcefully)
+image_ids=`docker images -aq`
+if test -n "$image_ids"
+then
+ # Some layers are deleted recursively and are no longer present
+ # when docker goes to remove them:
+ docker rmi -f `docker images -aq` || true
+fi
+