mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #38419 from thaJeztah/fix_nuke_everything
PowerShell: fix "Nuke-Everything" failing to remove images
This commit is contained in:
commit
e0e9942dc5
1 changed files with 6 additions and 10 deletions
|
@ -136,18 +136,14 @@ Function Nuke-Everything {
|
|||
if ($(docker ps -aq | Measure-Object -line).Lines -gt 0) {
|
||||
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) {
|
||||
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 {
|
||||
Write-Host -ForegroundColor Magenta "WARN: Skipping cleanup of images and containers"
|
||||
|
|
Loading…
Add table
Reference in a new issue