From 2c15101ad865eebe18c3e292ebbd00b0149c05e1 Mon Sep 17 00:00:00 2001 From: caadiq Date: Mon, 29 Dec 2025 13:57:09 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20docker=20compose=20=EC=8B=A4=ED=96=89=20?= =?UTF-8?q?=EC=8B=9C=20-f=EC=99=80=20--project-directory=20=EC=98=B5?= =?UTF-8?q?=EC=85=98=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - -f: 컨테이너 내부 경로로 compose 파일 지정 - --project-directory: 호스트 경로로 volumes 해석 - cwd 대신 명시적 경로 지정으로 ENOENT 에러 해결 --- backend/routes/admin.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/backend/routes/admin.js b/backend/routes/admin.js index 841120e..bdcbbd0 100644 --- a/backend/routes/admin.js +++ b/backend/routes/admin.js @@ -1178,10 +1178,11 @@ async function getRunningServer() { // 컨테이너 상태 확인 async function getContainerStatus(serverPath) { try { + const fullPath = path.join(SERVER_BASE_PATH, serverPath); const hostPath = path.join(HOST_SERVER_PATH, serverPath); + const composeFile = path.join(fullPath, "docker-compose.yml"); const { stdout } = await execAsync( - `docker compose ps --format json 2>/dev/null`, - { cwd: hostPath } + `docker compose -f "${composeFile}" --project-directory "${hostPath}" ps --format json 2>/dev/null` ); if (stdout.trim()) { const containers = stdout @@ -1260,11 +1261,14 @@ router.post("/servers/start", async (req, res) => { console.log(`[Admin] 서버 시작 중: ${serverPath}`); - // docker-compose up -d 실행 (호스트 경로 사용) - const { stdout, stderr } = await execAsync("docker compose up -d", { - cwd: hostPath, - timeout: 60000, // 60초 타임아웃 - }); + // docker compose up -d 실행 + // -f: 컨테이너 내부 경로로 파일 지정 + // --project-directory: 호스트 경로로 volumes 해석 + const composeFile = path.join(fullPath, "docker-compose.yml"); + const { stdout, stderr } = await execAsync( + `docker compose -f "${composeFile}" --project-directory "${hostPath}" up -d`, + { timeout: 60000 } + ); console.log(`[Admin] 서버 시작 완료: ${serverPath}`); res.json({ @@ -1302,11 +1306,12 @@ router.post("/servers/stop", async (req, res) => { console.log(`[Admin] 서버 종료 중: ${serverPath}`); - // docker-compose down 실행 (호스트 경로 사용) - const { stdout, stderr } = await execAsync("docker compose down", { - cwd: hostPath, - timeout: 60000, // 60초 타임아웃 - }); + // docker compose down 실행 + const composeFile = path.join(fullPath, "docker-compose.yml"); + const { stdout, stderr } = await execAsync( + `docker compose -f "${composeFile}" --project-directory "${hostPath}" down`, + { timeout: 60000 } + ); console.log(`[Admin] 서버 종료 완료: ${serverPath}`); res.json({