cleanup volumes as well

This commit is contained in:
Andras Bacsai
2023-08-16 15:26:33 +02:00
parent 702e16d643
commit a2d4373104
2 changed files with 7 additions and 2 deletions

View File

@@ -1762,7 +1762,7 @@ export function convertTolOldVolumeNames(type) {
}
}
export async function cleanupDockerStorage(dockerId) {
export async function cleanupDockerStorage(dockerId, volumes = false) {
// Cleanup images that are not used by any container
try {
await executeCommand({ dockerId, command: `docker image prune -af` });
@@ -1780,6 +1780,11 @@ export async function cleanupDockerStorage(dockerId) {
try {
await executeCommand({ dockerId, command: `docker builder prune -af` });
} catch (error) { }
if (volumes) {
try {
await executeCommand({ dockerId, command: `docker volume prune -a` });
} catch (error) { }
}
}
export function persistentVolumes(id, persistentStorage, config) {

View File

@@ -57,7 +57,7 @@ export async function cleanupManually(request: FastifyRequest) {
const destination = await prisma.destinationDocker.findUnique({
where: { id: serverId }
});
await cleanupDockerStorage(destination.id);
await cleanupDockerStorage(destination.id, true);
return {};
} catch ({ status, message }) {
return errorHandler({ status, message });