Repository navigation
Description
Summary
homelab_composeUp with stacks runs up -d --remove-orphans against only compose.base.yml plus the requested file. Every stack file lives in the same directory, so they all share one Compose project, and Compose removes the containers of every other stack as "orphans". Starting or updating one stack takes down the rest of the lab. homelab_composeDown with stacks has the mirror problem: it always adds compose.base.yml, so stopping one stack also stops every base service.
Related: #93
Where
mcp-server/src/utils/compose.ts:239(buildComposeCommand),:243-245mcp-server/src/tools/composeUp.ts:32mcp-server/src/tools/composeDown.ts:35skills/docker-compose-stacks/SKILL.md:46-48,:136
Details
if (stacks && stacks.length > 0) {
const files = ["-f compose.base.yml", ...stacks.map((s) => `-f ${s}`)].join(" ");
return `${cd}; docker compose ${files} ${action}`;
}composeUp passes action = "up -d --remove-orphans 2>&1". Compose names the project after the project directory (or a shared top-level name:), which is the same for every file in HOMELAB_COMPOSE_DIR. Containers of that project whose service is not in the files passed are orphans, and --remove-orphans deletes them.
The docker-compose-stacks skill recommends exactly this call for deploys and updates (homelab_composePull then homelab_composeUp with the same stacks) and says orphan removal only cleans "containers removed from the selected compose files", which is not what Compose does.
Impact
The documented "update one stack" workflow removes the containers of all other stacks (DNS, reverse proxy, password manager, ...). composeDown of a single stack also stops the base stack and its network.
Steps to reproduce
- Reference layout in
/opt/homelab/dockerwith all stack files up. - Call
homelab_composeUpwith{ "stacks": ["compose.monitoring.yml"], "confirm": true }. - Compose reports "Found orphan containers" and removes the containers from the apps, network, security, storage and tools files.
Suggested fix
- With a stack subset, do not pass
--remove-orphans. Better: always pass the full file list (so the project config is complete) and target the stack's services:docker compose <all files> up -d <services>, where the services come fromdocker compose -f <stack> config --services. - For
composeDownwithstacks, stop and remove only that stack's services (docker compose <all files> stop <services>thenrm -f <services>) instead ofdownon base + stack. - Keep
--remove-orphansonly for the "all stacks" path. - Correct the skill text at
SKILL.md:136.
Acceptance criteria
- composeUp with
stacksnever removes containers that belong to other stack files. - composeDown with
stacksleaves base services running. - Command tests cover the stack-subset case for up and down (today
confirm-gates.test.ts:61only checks the no-stacks command). - Skill describes the real behavior.
Getting started
- Relevant files:
mcp-server/src/utils/compose.ts,mcp-server/src/tools/composeUp.ts,mcp-server/src/tools/composeDown.ts,mcp-server/src/tools/__tests__/commands.test.ts - How to run tests:
cd mcp-server && npm install && npm test
Filed by repo-audit/full-audit at a59395f. Severity: high. Effort: M. audit-key: bug|mcp-server/src/utils/compose.ts|buildComposeCommand
Activity
TMHSDigital commentedon Nov 18, 2026
Fixed in 70e28d3. With
stacks, composeUp and composeDown now pass the full project file list and act only on the named stack's services (no--remove-orphansfor a subset; composeDown uses stop + rm and refusesremoveVolumes). Verified with new command and handler tests (350 passing) and by running the generated script against a stubdocker, which started/removed only the stack's services.