This is an automated email from the ASF dual-hosted git repository.
aw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yetus.git
The following commit(s) were added to refs/heads/master by this push:
new 035ec08 YETUS-758. docker-cleanup doesn't always clean
035ec08 is described below
commit 035ec084e0cacfd2f7629e4b0e096c625b040986
Author: Allen Wittenauer <[email protected]>
AuthorDate: Sun Feb 3 13:45:51 2019 -0800
YETUS-758. docker-cleanup doesn't always clean
Signed-off-by: Allen Wittenauer <[email protected]>
---
precommit/src/main/shell/core.d/docker.sh | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/precommit/src/main/shell/core.d/docker.sh
b/precommit/src/main/shell/core.d/docker.sh
index 12621d3..ec931e2 100755
--- a/precommit/src/main/shell/core.d/docker.sh
+++ b/precommit/src/main/shell/core.d/docker.sh
@@ -399,6 +399,31 @@ function docker_container_maintenance
${data})
}
+## @description Untag docker images for a given id
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param imageid
+function docker_untag_images
+{
+ declare id=$1
+ declare i
+ declare imagestr
+ declare -a images
+
+ # ["image1","image2","image3"]
+ imagestr=$(dockercmd inspect -f '{{json .RepoTags}}' "${id}")
+ imagestr=${imagestr#"["}
+ imagestr=${imagestr%"]"}
+ imagestr=${imagestr//\"}
+
+ yetus_comma_to_array images "${imagestr}"
+
+ for i in "${images[@]}"; do
+ dockercmd rmi "${i}"
+ done
+}
+
## @description Delete images after ${DOCKER_IMAGE_PURGE}
## @audience private
## @stability evolving
@@ -427,6 +452,7 @@ function docker_image_maintenance_helper
((difftime = curtime - createtime))
if [[ ${difftime} -gt ${DOCKER_IMAGE_PURGE} ]]; then
echo "Attempting to remove docker image ${id}"
+ docker_untag_images "${id}"
dockercmd rmi "${id}"
fi
done