Skip to content

Commit c13a68d

Browse files
authored
Merge pull request #1814 from Dokploy/1690-remove-unused-networks-when-removing-projects-or-apps
Enhance compose removal process by adding network disconnection command
2 parents 1eda651 + eb5ba2f commit c13a68d

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

packages/server/src/services/compose.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,9 @@ export const removeCompose = async (
478478
const projectPath = join(COMPOSE_PATH, compose.appName);
479479

480480
if (compose.composeType === "stack") {
481-
const command = `cd ${projectPath} && docker stack rm ${compose.appName} && rm -rf ${projectPath}`;
481+
const command = `
482+
docker network disconnect ${compose.appName} dokploy-traefik;
483+
cd ${projectPath} && docker stack rm ${compose.appName} && rm -rf ${projectPath}`;
482484

483485
if (compose.serverId) {
484486
await execAsyncRemote(compose.serverId, command);
@@ -489,12 +491,11 @@ export const removeCompose = async (
489491
cwd: projectPath,
490492
});
491493
} else {
492-
let command: string;
493-
if (deleteVolumes) {
494-
command = `cd ${projectPath} && docker compose -p ${compose.appName} down --volumes && rm -rf ${projectPath}`;
495-
} else {
496-
command = `cd ${projectPath} && docker compose -p ${compose.appName} down && rm -rf ${projectPath}`;
497-
}
494+
const command = `
495+
docker network disconnect ${compose.appName} dokploy-traefik;
496+
cd ${projectPath} && docker compose -p ${compose.appName} down ${
497+
deleteVolumes ? "--volumes" : ""
498+
} && rm -rf ${projectPath}`;
498499

499500
if (compose.serverId) {
500501
await execAsyncRemote(compose.serverId, command);

packages/server/src/services/settings.ts

-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ export const getServiceImageDigest = async () => {
4040
"docker service inspect dokploy --format '{{.Spec.TaskTemplate.ContainerSpec.Image}}'",
4141
);
4242

43-
console.log("stdout", stdout);
44-
4543
const currentDigest = stdout.trim().split("@")[1];
4644

4745
if (!currentDigest) {

0 commit comments

Comments
 (0)