Selaa lähdekoodia

Merge pull request #38419 from thaJeztah/fix_nuke_everything

PowerShell: fix "Nuke-Everything" failing to remove images
Sebastiaan van Stijn 6 vuotta sitten
vanhempi
commit
e0e9942dc5
1 muutettua tiedostoa jossa 6 lisäystä ja 10 poistoa
  1. 6 10
      hack/ci/windows.ps1

+ 6 - 10
hack/ci/windows.ps1

@@ -136,18 +136,14 @@ Function Nuke-Everything {
             if ($(docker ps -aq | Measure-Object -line).Lines -gt 0) {
             if ($(docker ps -aq | Measure-Object -line).Lines -gt 0) {
                 docker rm -f $(docker ps -aq)
                 docker rm -f $(docker ps -aq)
             }
             }
-            $imageCount=($(docker images --format "{{.Repository}}:{{.ID}}" | `
-                            select-string -NotMatch "windowsservercore" | `
-                            select-string -NotMatch "nanoserver" | `
-                            select-string -NotMatch "docker" | `
-                            Measure-Object -line).Lines)
+
+            $allImages  = $(docker images --format "{{.Repository}}#{{.ID}}")
+            $toRemove   = ($allImages | Select-String -NotMatch "windowsservercore","nanoserver","docker")
+            $imageCount = ($toRemove | Measure-Object -line).Lines
+
             if ($imageCount -gt 0) {
             if ($imageCount -gt 0) {
                 Write-Host -Foregroundcolor green "INFO: Non-base image count on control daemon to delete is $imageCount"
                 Write-Host -Foregroundcolor green "INFO: Non-base image count on control daemon to delete is $imageCount"
-                docker rmi -f `
-                    $(docker images --format "{{.Repository}}:{{.ID}}" | `
-                            select-string -NotMatch "windowsservercore" | `
-                            select-string -NotMatch "nanoserver" | `
-                            select-string -NotMatch "docker").ToString().Split(":")[1]
+                docker rmi -f ($toRemove | Foreach-Object { $_.ToString().Split("#")[1] })
             }
             }
         } else {
         } else {
             Write-Host -ForegroundColor Magenta "WARN: Skipping cleanup of images and containers"
             Write-Host -ForegroundColor Magenta "WARN: Skipping cleanup of images and containers"