mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
[fix] so-docker-prune breaks when multiple "so-" images share a version
This commit is contained in:
@@ -60,13 +60,17 @@ def main(quiet):
|
|||||||
no_prunable = True
|
no_prunable = True
|
||||||
for t_list in grouped_tag_lists:
|
for t_list in grouped_tag_lists:
|
||||||
try:
|
try:
|
||||||
# Keep the 2 most current images
|
# Group tags by version, in case multiple images exist with the same version string
|
||||||
t_list.sort(key=lambda x: Version(get_image_version(x)), reverse=True)
|
t_list.sort(key=lambda x: Version(get_image_version(x)), reverse=True)
|
||||||
if len(t_list) <= 2:
|
grouped_t_list = [ list(it) for _,it in groupby(t_list, lambda x: get_image_version(x)) ]
|
||||||
|
|
||||||
|
# Keep the 2 most current version groups
|
||||||
|
if len(grouped_t_list) <= 2:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
no_prunable = False
|
no_prunable = False
|
||||||
for tag in t_list[2:]:
|
for group in grouped_t_list[2:]:
|
||||||
|
for tag in group:
|
||||||
if not quiet: print(f'Removing image {tag}')
|
if not quiet: print(f'Removing image {tag}')
|
||||||
client.images.remove(tag)
|
client.images.remove(tag)
|
||||||
except InvalidVersion as e:
|
except InvalidVersion as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user