Skip to content

Commit

Permalink
docker prune containers
Browse files Browse the repository at this point in the history
  • Loading branch information
Cabecinha84 committed Jan 8, 2024
1 parent c424f3f commit d81afd7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
15 changes: 15 additions & 0 deletions ZelBack/src/services/appsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -3349,6 +3349,21 @@ async function registerAppLocally(appSpecs, componentSpecs, res) {
if (res) {
res.write(serviceHelper.ensureString(dockerImages2));
}

const dockerContainers = {
status: 'Clearing up unused docker containers...',
};
log.info(dockerContainers);
if (res) {
res.write(serviceHelper.ensureString(dockerContainers));
}
await dockerService.pruneContainers();
const dockerContainers2 = {
status: 'Docker containers cleaned.',
};
if (res) {
res.write(serviceHelper.ensureString(dockerContainers2));
}
// eslint-disable-next-line no-restricted-syntax
for (const stoppedApp of stoppedApps) {
// eslint-disable-next-line no-await-in-loop
Expand Down
10 changes: 9 additions & 1 deletion ZelBack/src/services/dockerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,14 @@ async function removeFluxAppDockerNetwork(appname) {
}

/**
* Remove all unused networks. Unused networks are those which are not referenced by any containers
* Remove all unused containers. Unused contaienrs are those wich are not running
*/
async function pruneContainers() {
return docker.pruneContainers();
}

/**
* Remove all unused networks. Unused networks are those which are not referenced by any running containers
*/
async function pruneNetworks() {
return docker.pruneNetworks();
Expand Down Expand Up @@ -970,6 +977,7 @@ module.exports = {
pruneNetworks,
pruneVolumes,
pruneImages,
pruneContainers,
dockerInfo,
dockerVersion,
dockerGetEvents,
Expand Down

0 comments on commit d81afd7

Please sign in to comment.