louislam/dockge · error · Error
Failed to delete, please check the terminal output for more
Error message
Failed to delete, please check the terminal output for more information.
What it means
Stack.delete() runs 'docker compose down --remove-orphans'; a non-zero exit code throws this Error and the stack folder is NOT removed (the fsAsync.rm happens only after success). Actual cause is visible in the compose terminal.
Source
Thrown at backend/stack.ts:220
fs.lchownSync(dir, uid, gid);
fs.chownSync(path.join(dir, this._composeFileName), uid, gid);
}
}
async deploy(socket : DockgeSocket) : Promise<number> {
const terminalName = getComposeTerminalName(socket.endpoint, this.name);
let exitCode = await Terminal.exec(this.server, socket, terminalName, "docker", this.getComposeOptions("up", "-d", "--remove-orphans"), this.path);
if (exitCode !== 0) {
throw new Error("Failed to deploy, please check the terminal output for more information.");
}
return exitCode;
}
async delete(socket: DockgeSocket) : Promise<number> {
const terminalName = getComposeTerminalName(socket.endpoint, this.name);
let exitCode = await Terminal.exec(this.server, socket, terminalName, "docker", this.getComposeOptions("down", "--remove-orphans"), this.path);
if (exitCode !== 0) {
throw new Error("Failed to delete, please check the terminal output for more information.");
}
// Remove the stack folder
await fsAsync.rm(this.path, {
recursive: true,
force: true
});
return exitCode;
}
async updateStatus() {
let statusList = await Stack.getStatusList();
let status = statusList.get(this.name);
if (status) {
this._status = status;
} else {View on GitHub (pinned to f809ae192b)
Solutions
- Read the compose terminal output in Dockge for the docker error
- Ensure compose.yaml still matches the running project before deleting (don't empty it first)
- Run 'docker compose down --remove-orphans' manually in the stack dir to diagnose
- If containers are stuck, 'docker rm -f' them / restart Docker, then delete again
- If the folder remains after a partial failure, remove it manually after confirming containers are gone
Example fix
// before
await stack.delete(socket);
// after
try {
await stack.delete(socket);
} catch (e) {
log.error("delete", `Compose down failed; stack folder for '${stack.name}' was kept. Fix compose.yaml or remove containers manually.`);
throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
import { existsSync, readFileSync } from "fs";
function canDelete(dir: string): boolean {
return existsSync(dir) && existsSync(dir + "/compose.yaml")
&& readFileSync(dir + "/compose.yaml", "utf8").trim().length > 0;
}
if (!canDelete(stack.path)) {
throw new Error("compose.yaml missing/empty — down would fail; restore it before deleting");
}
await stack.delete(socket); Type guard
function isDeletable(stack: Stack): boolean {
return typeof stack.name === "string" && stack.name.length > 0 && !!stack.composeYAML;
} Try / catch
try {
await stack.delete(socket);
} catch (e) {
log.error("delete", "Compose down failed — stack folder retained; fix compose.yaml or remove containers manually, then retry");
throw e;
} Prevention
- Never empty or rename compose.yaml right before deleting a stack
- Confirm docker daemon is healthy before teardown operations
- Clean up orphaned networks/containers periodically
- If down keeps failing, remove containers with docker rm -f first
When it happens
Trigger: docker compose down exits non-zero: compose.yaml already deleted/edited so project name or services can't be resolved, Docker daemon error, orphan-network removal failure, containers in a stuck state.
Common situations: User edited compose.yaml (renamed project/services) then deleted — down can't find original resources; daemon restarting/unreachable; leftover networks with 'down' failing on external network marked external.
Related errors
- Failed to deploy, please check the terminal output for more
- Failed to start, please check the terminal output for more i
- Failed to stop, please check the terminal output for more in
- Failed to restart, please check the terminal output for more
- Failed to down, please check the terminal output for more in
AI-assisted analysis of louislam/dockge@f809ae192b (2026-08-31).
Data as JSON: /api/errors/93d399364cde4e88.
Report an issue: GitHub.