Skip to content

Adding option to remove only containers created by AL-Go. #3983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions ContainerHandling/Flush-ContainerHelperCache.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,19 @@ try {
$exitedDaysAgo = [DateTime]::Now.Subtract($finishedAt).Days
if ($exitedDaysAgo -ge $keepDays) {
if (($inspect.Config.Labels.psobject.Properties.Match('maintainer').Count -ne 0 -and $inspect.Config.Labels.maintainer -eq "Dynamics SMB")) {
Write-Host "Removing container $containerName"
docker rm $containerID -f
if ($caches.Contains('ALGoContainersOnly')) {
if ($inspect.Config.Labels.psobject.Properties.Match('creator').Count -ne 0 -and $inspect.Config.Labels.creator -eq "AL-Go") {
Write-Host "Removing container $containerName"
docker rm $containerID -f
}
else {
Write-Host "Container $containerName (exited $exitedDaysAgo day$(if($exitedDaysAgo -ne 1){'s'}) ago) is recognized as a Business Central Container, but was not created by AL-Go - not removing"
}
}
else {
Write-Host "Removing container $containerName"
docker rm $containerID -f
}
}
else {
Write-Host "Container $containerName (exited $exitedDaysAgo day$(if($exitedDaysAgo -ne 1){'s'}) ago) is not recognized as a Business Central Container - not removing"
Expand Down