From cb64482649cba0717a55da30c181ecf4bc45527c Mon Sep 17 00:00:00 2001 From: Mauricio Siu Date: Thu, 9 Apr 2026 17:06:09 -0600 Subject: [PATCH] fix: inject COMPOSE_PROJECT_NAME to prevent orphaned containers on redeploy When users set a custom docker compose command without the -p flag, Docker Compose defaults to using the directory name (code) as the project name. If the custom command is later removed, Dokploy uses -p appName, creating a new stack while the old one remains running. Injecting COMPOSE_PROJECT_NAME=appName into the .env ensures the project name is always consistent regardless of the command used. Closes #4019 --- packages/server/src/utils/builders/compose.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/server/src/utils/builders/compose.ts b/packages/server/src/utils/builders/compose.ts index 316570626..8da1b6678 100644 --- a/packages/server/src/utils/builders/compose.ts +++ b/packages/server/src/utils/builders/compose.ts @@ -106,6 +106,7 @@ export const getCreateEnvFileCommand = (compose: ComposeNested) => { const envFilePath = join(dirname(composeFilePath), ".env"); let envContent = `APP_NAME=${appName}\n`; + envContent += `COMPOSE_PROJECT_NAME=${appName}\n`; envContent += env || ""; if (!envContent.includes("DOCKER_CONFIG")) { envContent += "\nDOCKER_CONFIG=/root/.docker";