블로그 목록으로
Mac Mini 프로덕션 서버 - Colima docker.sock 6일 주기 끊김 디버깅
증상
colima status → running (정상)
docker ps → Cannot connect to the Docker daemon at unix:///Users/your-username/.colima/default/docker.sock.
Is the docker daemon running?
서버 다운 이력:
- 1차: 2026-06-04 18:00:19 KST
- 2차: 2026-06-10 22:17:38 KST (+6일 4시간 17분)
- 3차: 2026-06-17 05:36:02 KST (+6일 7시간 18분)
- 4차: 2026-06-22 16:10:20 KST (+5일 10시간 34분)
- 5차: 2026-07-12 약 14:57 KST — qemu 전환(7/6) 후에도 재발 (+약 6일)
디버깅 과정 (1차 — vz 환경)
Step 1. 기본 상태 확인
colima statusINFO[0000] colima is running using macOS Virtualization.Framework
INFO[0000] arch: aarch64
INFO[0000] runtime: docker
INFO[0000] mountType: virtiofs
INFO[0000] docker socket: unix:///Users/your-username/.colima/default/docker.sock
INFO[0000] containerd socket: unix:///Users/your-username/.colima/default/containerd.sock
ls -la ~/.colima/default/docker.socksrw------- 1 your-username staff 0 Jun 17 11:44 /Users/your-username/.colima/default/docker.sock
→ 파일은 있지만 시각이 마지막 재시작 시점(Jun 17)에 고정되어 있음. 껍데기만 남은 상태.
Step 2. macOS 슬립 의심 → 제외
pmset -gdisplaysleep 0
disksleep 10
sleep 0 (sleep prevented by powerd)
networkoversleep 0
standby 0
→ sleep 0, displaysleep 0, standby 0 모두 비활성화. 슬립 제외.
Step 3. Colima 설치 시점 확인
ls -la $(brew --prefix)/Cellar/colima/total 0
drwxr-xr-x 3 your-username admin 96 May 2 23:29 .
drwxrwxr-x 31 your-username admin 992 May 3 15:03 ..
drwxr-xr-x 12 your-username admin 384 May 2 23:29 0.10.1
→ 2026-05-02 Colima 0.10.1 설치. 첫 다운이 2026-06-04이니 설치 후 33일 후 첫 발생.
Step 4. Colima 설정 확인 → vmType: vz 발견
cat ~/.colima/default/colima.yamlcpu: 8
disk: 150
memory: 12
arch: aarch64
vmType: vz # ← Apple Virtualization Framework
mountType: virtiofs # ← vz 전용, 가장 빠르지만 불안정
mountInotify: true # ← experimentalStep 5. fd 누수 의심 → 제외
colima sshLima VM 안에서:
sudo ls /proc/$(pgrep dockerd)/fd | wc -l51
cat /proc/$(pgrep dockerd)/limits | grep -i "open files"Max open files 1048576 1048576 files
→ 한도 1,048,576에 현재 51개. fd 누수 제외.
Step 6. macOS 프로세스 확인
ps aux | grep -E "colima|lima|ssh" | grep -v grepyour-username 66683 0.0 0.6 ... Wed11AM 1:58.91 /opt/homebrew/bin/limactl hostagent --pidfile /Users/your-username/.colima/_lima/colima/ha.pid ...
your-username 66676 0.0 0.3 ... Wed11AM 11:54.21 /opt/homebrew/bin/limactl usernet ...
your-username 37493 0.0 0.0 ... 4:13PM 0:00.00 ssh: /Users/your-username/.colima/_lima/colima/ssh.sock [mux]
→ limactl hostagent는 Wed11AM(Jun 17)부터 실행 중. SSH mux는 디버깅 시작할 때 생긴 것.
ps aux | grep virtiofsd | grep -v grep(출력 없음)
→ vmType: vz는 Apple Virtualization Framework 내장 방식이라 별도 virtiofsd 프로세스 없음.
Step 7. dockerd 생사 확인 → 살아있음
colima ssh -- docker ps→ 컨테이너 목록 정상 출력. dockerd 살아있음 확정.
Lima VM 접속 후:
pgrep dockerd1325
systemctl status docker● docker.service - Docker Application Container Engine
Active: active (running) since Wed 2026-06-17 11:44:30 KST; 5 days ago
Main PID: 1325 (dockerd)
Tasks: 76
Memory: 79.8M (peak: 119.5M)
CPU: 6min 18.458s
CGroup: /system.slice/docker.service
├─1325 /usr/bin/dockerd ...
├─1830 /usr/bin/docker-proxy -proto tcp -host-port 3001 ...
├─1914 /usr/bin/docker-proxy -proto tcp -host-port 80 ...
└─1936 /usr/bin/docker-proxy -proto tcp -host-port 443 ...
→ dockerd + 컨테이너 모두 정상 실행 중. dockerd 크래시가 아님.
Step 8. SSH 컨텍스트 우회 시도 → 실패 (컨텍스트 없음)
docker --context colima-ssh psFailed to initialize: unable to resolve docker endpoint: context "colima-ssh": context not found:
open /Users/your-username/.docker/contexts/meta/<context-hash>.../meta.json: no such file or directory
→ colima-ssh 컨텍스트 없음. 소켓만 사용하는 구조.
Step 9. dockerd 로그 확인 → 크래시 없음
Lima VM 안에서:
sudo journalctl -u docker --since "6 days ago" --no-pager | tail -100Jun 17 11:43:12 colima dockerd[1314]: time="..." level=info msg="Processing signal 'terminated'"
Jun 17 11:43:12 colima dockerd[1314]: time="..." level=info msg="Daemon shutdown complete"
Jun 17 11:43:12 colima systemd[1]: Stopped docker.service
-- Boot <lima-boot-id> -- ← Lima VM 재부팅
Jun 17 11:44:30 colima dockerd[1325]: time="..." level=info msg="Starting up"
Jun 17 11:44:30 colima dockerd[1325]: time="..." level=info msg="API listen on /run/docker.sock"
Jun 17 11:44:30 colima systemd[1]: Started docker.service
(이후 Jun 22까지 error/fatal 없음)
→ Jun 17 이후 dockerd는 한 번도 죽지 않음. 로그에 이상 없음.
Step 10. hostagent 로그 확인 → 당시 가설 (vz 클럭)
cat ~/.colima/_lima/colima/ha.stderr.log | tail -100{"level":"info","msg":"Time sync: guest clock adjusted (was 2052ms off)","time":"2026-06-22T16:12:42+09:00"}
{"level":"info","msg":"Time sync: guest clock adjusted (was 2054ms off)","time":"2026-06-22T16:12:52+09:00"}
{"level":"info","msg":"Time sync: guest clock adjusted (was 2043ms off)","time":"2026-06-22T16:13:02+09:00"}
{"level":"info","msg":"Time sync: guest clock adjusted (was 2048ms off)","time":"2026-06-22T16:13:12+09:00"}→ 당시 10초마다 ~2초씩 Lima VM 시계가 느려지고 있음을 확인. vmType: vz의 가상 클럭 버그로
추정했다.
grep -E "error|socket|forward" ~/.colima/_lima/colima/ha.stderr.log | tail -50{"level":"info","msg":"hostagent socket created at /Users/your-username/.colima/_lima/colima/ha.sock","time":"2026-06-17T11:44:21+09:00"}
{"level":"debug","msg":"Forwarding unix sockets","time":"2026-06-17T11:44:26+09:00"}
{"level":"debug","msg":"Running \"/usr/bin/ssh ... -O forward -L /Users/your-username/.colima/default/docker.sock:/var/run/docker.sock ...\"","time":"2026-06-17T11:44:26+09:00"}
{"error":"failed to run [...] -L 0.0.0.0:443:0.0.0.0:443 ...]: exit status 255","level":"warning","msg":"failed to set up forwarding tcp port 443 (negligible if already forwarded)","time":"2026-06-17T11:45:02+09:00"}
→ Jun 17 11:44:26에 docker.sock 포워딩 SSH 명령 실행 후 재설정 기록 없음. → ControlMaster가 죽었지만 hostagent가 재연결하지 않음. 소켓은 껍데기로 남음. (이 부분은 이후에도 동일하게 유효)
당시 원인 가설 (vz)
vmType: vz → 가상 클럭이 10초마다 2초씩 드리프트
→ hostagent가 계속 교정하지만 튀는 순간 SSH keepalive 응답 지연
→ SSH ControlMaster 연결 종료
→ docker.sock 포워딩 소실 (hostagent는 재연결 안 함)
→ colima status: running (Lima VM은 살아있음)
→ docker ps: 실패 (macOS ↔ VM 소켓 연결만 끊김)
이 가설로 qemu 전환을 진행했다. 클럭 드리프트는 줄었지만, 같은 증상은 재발했다.
긴급 복구 (재시작 없이)
colima ssh를 실행하면 SSH mux가 살아나므로, 그 위에 소켓 포워딩만 재추가.
SSH 포트는 인스턴스마다 다르다. 하드코딩하지 말고 먼저 확인한다.
# SSH 포트 확인 (예: 55221)
grep -iE '^\s*port\s' ~/.colima/_lima/colima/ssh.config
# 또는
awk '/^[[:space:]]*[Pp]ort[[:space:]]/ {print $2; exit}' ~/.colima/_lima/colima/ssh.config# 0. mux가 죽어 있으면 먼저 깨우기
colima ssh -- true
# 1. 죽은 소켓 파일 제거
rm -f ~/.colima/default/docker.sock
# 2. docker.sock 포워딩 재설정 (-p 는 위에서 확인한 포트)
ssh \
-o IdentityFile="$HOME/.colima/_lima/_config/user" \
-o StrictHostKeyChecking=no \
-o NoHostAuthenticationForLocalhost=yes \
-o BatchMode=yes \
-o IdentitiesOnly=yes \
-o "ControlPath=$HOME/.colima/_lima/colima/ssh.sock" \
-O forward \
-L "$HOME/.colima/default/docker.sock:/var/run/docker.sock" \
-p <SSH_PORT> 127.0.0.1
# 3. 포트도 끊겼으면 80/443 재연결
ssh \
-o IdentityFile="$HOME/.colima/_lima/_config/user" \
-o StrictHostKeyChecking=no \
-o NoHostAuthenticationForLocalhost=yes \
-o BatchMode=yes \
-o IdentitiesOnly=yes \
-o "ControlPath=$HOME/.colima/_lima/colima/ssh.sock" \
-O forward \
-L "0.0.0.0:443:0.0.0.0:443" \
-p <SSH_PORT> 127.0.0.1
ssh \
-o IdentityFile="$HOME/.colima/_lima/_config/user" \
-o StrictHostKeyChecking=no \
-o NoHostAuthenticationForLocalhost=yes \
-o BatchMode=yes \
-o IdentitiesOnly=yes \
-o "ControlPath=$HOME/.colima/_lima/colima/ssh.sock" \
-O forward \
-L "0.0.0.0:80:0.0.0.0:80" \
-p <SSH_PORT> 127.0.0.1
# 4. 확인
docker ps안 되면:
colima restart
docker ps복구 직후 CSS/정적 파일이 깨질 때
sock만 다시 붙이고 80/443이 반쯤만 복구되면 HTML은 뜨고 CSS가 깨질 수 있다. nginx·next를
재시작하거나, 애매하면 colima restart가 더 확실하다.
docker restart nginx next-prod
# 또는
docker compose -f docker-compose.prod.yml restartcompose up 시 nginx.conf 마운트 에러
error mounting ".../nginx.conf" ... not a directory:
Are you trying to mount a directory onto a file (or vice-versa)?
호스트의 nginx.conf 경로가 없거나 Colima(sshfs) 마운트가 어긋나면 Docker가 그 경로에 빈
디렉터리를 만들어 버린다. 파일 마운트가 디렉터리→파일로 실패한다.
ls -la path/to/docker/nginx/nginx.conf
# directory 이면 삭제 후 git에서 파일 복구
rm -rf path/to/docker/nginx/nginx.conf
git checkout -- path/to/docker/nginx/nginx.conf
docker compose -f docker-compose.prod.yml up -d시도: vmType qemu 전환
vmType 변경은 VM 완전 재생성이 필요해서 컨테이너/이미지/볼륨이 초기화된다.
colima delete 후 colima start만 하면 macOS 13.5+ Apple Silicon에서는 기본값이 다시 vz로
잡히므로, start 시 플래그로 명시해야 한다.
# qemu가 없으면 먼저 설치
brew install qemu
colima stop
colima delete
colima start \
--cpu 6 \
--memory 8 \
--disk 150 \
--arch aarch64 \
--vm-type qemu \
--mount-type sshfs \
--mount-inotify=false
# 적용 확인
cat ~/.colima/default/colima.yaml
docker-compose -f docker-compose.prod.yml up -d --buildcolima.yaml에서 아래 항목이 맞으면 정상 적용된 것이다.
vmType: qemu
mountType: sshfs
mountInotify: false→ 2026-07-06 qemu로 전환. vz 클럭 드리프트(수 초)는 사라졌다.
→ 그러나 2026-07-12에 동일 증상 재발. qemu만으로는 해결되지 않았다.
2차 재발 검증 (2026-07-12, qemu)
확인 결과
| 항목 | 결과 |
|---|---|
colima status | running, QEMU, mountType sshfs |
docker ps (Mac) | 실패 |
colima ssh -- docker ps | 성공 (컨테이너 Up 6 days) |
lsof ~/.colima/default/docker.sock | 출력 없음 (listener 없음) |
docker.sock mtime | Jul 6 08:08에 고정 (껍데기) |
| hostagent | Jul 6 08:08부터 6일째 생존 |
| Time sync | drift 4~14ms (vz의 2초 드리프트 아님) |
colima ssh 시:
mux_client_request_session: read from master failed: Broken pipe
ControlSocket .../ssh.sock already exists, disabling multiplexing
→ SSH ControlMaster(mux)가 죽은 상태. VM·dockerd는 정상.
hostagent 로그에서 확정된 구조
docker.sockforward는 Jul 6 08:08:32에 단 1회만 기록됨. 이후 재등록 없음.- mux 사망 후 hostagent는
ga.sock(guest-agent)만 10초마다 재시도한다. - mux가 다시 살아나도 docker.sock은 자동으로 다시 붙이지 않는다.
SSH ControlMaster 사망 (로그에 사망 시각은 안 남음, silent)
→ docker.sock / (대개) 80·443 포워딩 소실
→ hostagent는 ga.sock만 재시도
→ Mac docker CLI 실패, VM 안 컨테이너는 계속 Up
검증된 근본 원인
Colima(Lima) on macOS:
docker CLI → ~/.colima/default/docker.sock
→ SSH ControlMaster (mux)
→ VM /var/run/docker.sock → dockerd
직접 원인: ControlMaster가 조용히 죽음
구조 원인: hostagent가 docker.sock 포워딩을 재등록하지 않음
트리거: vz 클럭은 한 가지 가능 원인일 뿐.
qemu에서도 ~6일 주기로 재발 → vmType과 무관한 SSH mux 의존 구조
Colima를 쓰는 한 “끊김 자체를 설정만으로 없애기”는 어렵다. 현실적 대응은 **자동 복구(워치독)**다.
재발 방지: 워치독
10분마다 docker ps 실패 시 소켓 재 forward → 실패하면 colima restart.
#!/bin/bash
# ~/bin/colima-watchdog.sh
set -euo pipefail
export PATH="/opt/homebrew/bin:/usr/bin:/bin:$PATH"
SOCK="$HOME/.colima/default/docker.sock"
CP="$HOME/.colima/_lima/colima/ssh.sock"
PORT="$(awk '/^[[:space:]]*[Pp]ort[[:space:]]/ {print $2; exit}' \
"$HOME/.colima/_lima/colima/ssh.config" 2>/dev/null || true)"
PORT="${PORT:-55221}"
if docker ps >/dev/null 2>&1; then
exit 0
fi
# mux 깨우기
colima ssh -- true >/dev/null 2>&1 || true
rm -f "$SOCK"
ssh \
-o IdentityFile="$HOME/.colima/_lima/_config/user" \
-o StrictHostKeyChecking=no \
-o NoHostAuthenticationForLocalhost=yes \
-o BatchMode=yes \
-o IdentitiesOnly=yes \
-o "ControlPath=$CP" \
-O forward \
-L "$SOCK:/var/run/docker.sock" \
-p "$PORT" 127.0.0.1 || true
if docker ps >/dev/null 2>&1; then
logger -t colima-watchdog "docker.sock re-forwarded"
exit 0
fi
logger -t colima-watchdog "re-forward failed, colima restart"
colima restart
logger -t colima-watchdog "colima restarted"chmod +x ~/bin/colima-watchdog.shmacOS는 launchd로 10분마다 실행한다. (~/Library/LaunchAgents/...plist, StartInterval=600)
SSH 포트를 고정하면 스크립트가 단순해진다.
colima start ... --ssh-port 55221자동 업데이트 방지
brew pin colima
# 적용 확인
brew list --pinned
brew info colimabrew list --pinned 출력에 colima가 있으면 고정된 것이다. brew info colima에서도 Pinned
표시를 확인할 수 있다.
고정 해제:
brew unpin colima참고: pin을 풀고 Colima/Lima를 올리면 hostagent 수정이 들어올 수는 있다. 다만 “업그레이드 = 완치”는 보장되지 않는다.
Q&A
긴급 복구 후 이대로 두면 재발하나?
재발한다. 긴급 복구는 끊어진 SSH 포워딩을 수동으로 이어붙인 것뿐이다. qemu로 바꿔도 ControlMaster가 죽으면 동일 증상이 반복된다. 워치독을 두는 것이 현실적인 재발 대응이다.
qemu로 바꾸면 해결되나?
클럭 드리프트는 줄지만, docker.sock 끊김은 해결되지 않았다. (7/6 전환 → 7/12 재발)
vz + virtiofs가 빠른 건 macOS ↔ VM 간 파일 I/O 속도다. 프로덕션 서빙 체감 차이는 거의 없다. 장기 운영에서는 여전히 SSH mux + hostagent 미복구 리스크가 남는다.
| vz | qemu | |
|---|---|---|
| 파일 I/O 속도 | 빠름 | 느림 |
| 가상 클럭 안정성 | 불안정 (버그) | 안정적 |
| 프로덕션 서빙 체감 차이 | 없음 | 없음 |
| docker.sock 장기 안정성 | SSH 끊김 재발 | 역시 재발 |
왜 이런 현상이 발생하나?
Colima는 Lima 위에서 Docker를 돌리고, Mac의 docker.sock은 SSH ControlMaster로 VM 소켓을
포워딩한다.
- ControlMaster가 장시간 후 조용히 죽음 (사망 시각은 로그에 잘 안 남음)
- hostagent는
ga.sock만 재시도하고docker.sock은 재등록하지 않음 - Mac
docker ps/lsof docker.sock실패·먹통, VM 안 컨테이너는 계속 실행
vz에서는 가상 클럭 드리프트가 SSH keepalive를 깨는 트리거가 될 수 있다. qemu에서는 클럭은 안정적인데 mux 자체 불안정으로도 같은 결과가 난다.
근본적으로 끊김을 없애려면?
Colima를 유지하는 한 SSH 소켓 포워딩 구조를 설정만으로 없애기는 어렵다.
| 방향 | 의미 |
|---|---|
| 워치독 | Colima 유지 + 자동 복구 |
| Docker Desktop / OrbStack 등 | SSH sock 구조 자체 제거 |
| Linux에 Docker 직접 | 가장 안정적 (Mac Mini면 듀얼부트 등) |
참고 이슈
채팅 문의

