diff --git a/run.ps1 b/run.ps1 index a332f62..64ec17e 100644 --- a/run.ps1 +++ b/run.ps1 @@ -140,9 +140,15 @@ function Create-Dir($str) { } } -function Docker-Prune { - docker image prune --all --force --filter="label=com.bitwarden.product=bitwarden" ` - --filter="label!=com.bitwarden.project=setup" +function Docker-Prune([switch] $all) { + if ($all) { + docker image prune --all --force --filter="label=com.bitwarden.product=bitwarden" + } + else { + docker image ls --format "{{.Repository}}:{{.Tag}}" --filter="label=com.bitwarden.product=bitwarden" | + Where-Object { $_ -notmatch '/bitwarden/setup' } | + ForEach-Object { docker image rm $_ } + } } function Update-Lets-Encrypt { @@ -217,10 +223,10 @@ function Uninstall() { } Write-Host "(!) " -f red -nonewline - $purgeAction = $( Read-Host "Would you like to purge all local Bitwarden container images? (y/n)" ) + $purgeAction = $( Read-Host "Would you like to purge all local Bitwarden container images (this will not remove third-party images such as certbot)? (y/n)" ) if ($purgeAction -eq "y") { - Docker-Prune + Docker-Prune -all } } diff --git a/run.sh b/run.sh index 0fcc79f..78be224 100755 --- a/run.sh +++ b/run.sh @@ -163,8 +163,15 @@ function createDir() { } function dockerPrune() { - docker image prune --all --force --filter="label=com.bitwarden.product=bitwarden" \ - --filter="label!=com.bitwarden.project=setup" + if [ "$1" == 'all' ] + then + docker image prune --all --force --filter="label=com.bitwarden.product=bitwarden" + else + for image in $(docker image ls --format "{{.Repository}}:{{.Tag}}" --filter="label=com.bitwarden.product=bitwarden" | grep -v '/bitwarden/setup'); do + docker image rm "$image" + done + fi + } function updateLetsEncrypt() { @@ -274,11 +281,11 @@ function uninstall() { exit 1 fi - echo -e -n "${RED}(!) Would you like to purge all local Bitwarden container images? (y/n): ${NC}" + echo -e -n "${RED}(!) Would you like to purge all local Bitwarden container images (this will not remove third-party images such as certbot)? (y/n): ${NC}" read PURGE_ACTION if [ "$PURGE_ACTION" == "y" ] then - dockerPrune + dockerPrune all echo -e -n "${CYAN}Bitwarden uninstall complete! ${NC}" fi }