From d8ad88bdb95c09c94c85bae9d513b0e9be6843e5 Mon Sep 17 00:00:00 2001 From: Dexter Yan Date: Tue, 3 Sep 2024 11:07:14 +1200 Subject: [PATCH] fix(kURL): add pre-check to remove docker in AL2 (#5382) --- scripts/common/docker.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/common/docker.sh b/scripts/common/docker.sh index f3502760ea..18214dccfc 100644 --- a/scripts/common/docker.sh +++ b/scripts/common/docker.sh @@ -238,14 +238,21 @@ function uninstall_docker_new_installs_with_containerd() { ;; centos|rhel|amzn|ol) - local dockerPackages=("docker.io" "docker-ce" "docker-ce-cli") + local dockerPackages=("docker" "docker.io" "docker-ce" "docker-ce-cli") if rpm -qa | grep -q 'docker-ce-rootless-extras'; then dockerPackages+=("docker-ce-rootless-extras") fi if rpm -qa | grep -q 'docker-scan-plugin'; then dockerPackages+=("docker-scan-plugin") fi - rpm --erase ${dockerPackages[@]} + local installedDockerPackages=() + # Check if each Docker-related package is installed and add to the list if so + for package in "${dockerPackages[@]}"; do + if sudo rpm -q "$package" &>/dev/null; then + installedPackages+=("$package") + fi + done + rpm --erase ${installedPackages[@]} ;; esac