Use docker cli to cleanup old images
This commit is contained in:
@@ -95,14 +95,7 @@ function emitPlatformReady() {
|
||||
function removeOldImages(callback) {
|
||||
debug('removing old addon images');
|
||||
|
||||
for (var imageName in infra.images) {
|
||||
const image = infra.images[imageName];
|
||||
const tag = image.tag.replace(/:.*@/, '@'); // this remove the semver tag
|
||||
debug('cleaning up images of %j', image);
|
||||
// older docker images did not have sha256 and thus have it as <none>
|
||||
const cmd = `docker images --digests "${image.repo}" | tail -n +2 | awk '{ print $1 ($3=="<none>" ? (":" $2) : ("@" $3)) }' | grep -v "${tag}" | xargs --no-run-if-empty docker rmi`;
|
||||
shell.execSync('removeOldImagesSync', cmd);
|
||||
}
|
||||
shell.execSync('removeOldImagesSync', 'docker image prune --force --all');
|
||||
|
||||
callback();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user