diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts index 8ec5a1e8a..c03213904 100644 --- a/apps/api/src/lib/common.ts +++ b/apps/api/src/lib/common.ts @@ -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) { diff --git a/apps/api/src/routes/api/v1/handlers.ts b/apps/api/src/routes/api/v1/handlers.ts index 4d6cd0b5c..ae663f447 100644 --- a/apps/api/src/routes/api/v1/handlers.ts +++ b/apps/api/src/routes/api/v1/handlers.ts @@ -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 });