Skip to content

Commit cc3ef5d

Browse files
author
박성모
committed
fix(install): stop orphan containers before compose_up to prevent port conflicts
On a retried install, a previous run may have left a partially-started container still holding port 18789. compose_up then fails with: failed to bind host port 127.0.0.1:18789/tcp: address already in use Run 'docker compose down --remove-orphans' before 'docker compose up' to clean up stale containers from this compose project. Volumes are preserved. Unrelated containers are not touched. Update TROUBLESHOOTING 원인 A with two sub-cases: orphan openclaw container (A-1, auto-fixed by v0.1.10+) and different app on port (A-2) with the correct port numbers (18789/18790, not 8000).
1 parent 6f9151c commit cc3ef5d

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

docs/TROUBLESHOOTING.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -612,13 +612,24 @@ docker compose -f "$OPENCLAW_DIR"/docker-compose.yml -f openclaw-mgr/compose.sec
612612

613613
**원인 A — 호스트 포트 점유**
614614
```
615-
Error: bind: address already in use
615+
Error response from daemon: failed to bind host port 127.0.0.1:18789/tcp: address already in use
616616
```
617-
충돌하는 포트를 찾고 점유 프로세스를 처리:
617+
618+
**케이스 A-1 — 이전 실패 실행의 잔여 openclaw 컨테이너**
619+
설치를 재시도했는데 이전 실패 실행에서 반쯤 기동된 컨테이너가 포트를 잡고 있는 경우입니다. v0.1.10 이상은 `compose_up` 전에 `docker compose down --remove-orphans` 로 자동 정리합니다. 이전 버전:
620+
```bash
621+
cd "$OPENCLAW_DIR"
622+
docker compose down --remove-orphans
623+
# 마커 리셋 후 재시도
624+
sed -i '' '/^compose_up=done$/d' ~/.openclaw-mgr/state
625+
./openclaw install
626+
```
627+
628+
**케이스 A-2 — 다른 앱이 포트 18789 사용 중**
618629
```bash
619-
# OpenClaw 가 쓰는 포트(.env 의 OPENCLAW_PORT, 기본 8000) 점유 확인
620-
lsof -nP -iTCP:8000 -sTCP:LISTEN
621-
# 다른 앱이라면 종료하거나, .env 의 OPENCLAW_PORT 를 8001 등 다른 번호로 변경
630+
lsof -nP -iTCP:18789 -sTCP:LISTEN # 점유 프로세스 확인
631+
# 다른 앱이면 종료하거나 .env 의 OPENCLAW_GATEWAY_PORT 를 변경:
632+
# OPENCLAW_GATEWAY_PORT=18800
622633
```
623634

624635
**원인 B — 이미지 pull 실패**

openclaw-mgr/cmd/install.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,16 @@ step_compose_up() {
328328
bash "$OPENCLAW_MGR_DIR/cmd/network.sh" online >/dev/null
329329
local net="$OPENCLAW_MGR_DIR/compose.network.yml"
330330
[ -f "$net" ] && files="$files -f $net"
331+
332+
# ── 이전 실패 실행의 잔여 컨테이너 정리 ─────────────────────────────────
333+
# 설치 재시도 시 이전 실행에서 반쯤 기동된 컨테이너가 남아 포트를 점유하면
334+
# "failed to bind host port: address already in use"
335+
# 오류가 난다. compose down --remove-orphans 로 이 프로젝트의 컨테이너를
336+
# 먼저 정리하고 새로 띄운다. 볼륨(데이터)은 보존된다.
337+
info "이전 컨테이너 잔재 정리 (포트 충돌 방지)..."
338+
# shellcheck disable=SC2086
339+
docker compose $files down --remove-orphans 2>/dev/null || true
340+
331341
# shellcheck disable=SC2086
332342
# --pull missing: 이미 받은 이미지는 재다운로드 안 함
333343
docker compose $files up -d --pull missing

0 commit comments

Comments
 (0)