@extends('layouts.app')

@section('title', 'Docker 명령어')

@push('styles')
<style>
    .help-balloon-trigger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: #eff6ff;
        color: #1d4ed8;
        font-size: 11px;
        font-weight: 700;
        cursor: pointer;
        border: 1.5px solid #93c5fd;
        vertical-align: middle;
        margin-left: 4px;
        transition: all 0.15s ease;
        position: relative;
        user-select: none;
    }
    .help-balloon-trigger:hover {
        background: #1d4ed8;
        color: white;
        border-color: #3b82f6;
    }
    .help-balloon {
        display: none;
        position: absolute;
        bottom: calc(100% + 10px);
        left: 50%;
        transform: translateX(-50%) scale(0.95);
        background: #1e293b;
        color: #f1f5f9;
        font-size: 12px;
        font-weight: 400;
        line-height: 1.6;
        padding: 10px 14px;
        border-radius: 10px;
        max-width: 300px;
        min-width: 200px;
        width: max-content;
        white-space: normal;
        word-break: keep-all;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
        z-index: 40;
        opacity: 0;
        transition: opacity 0.15s ease, transform 0.15s ease;
        pointer-events: none;
    }
    .help-balloon::after {
        content: '';
        position: absolute;
        top: 100%;
        left: 50%;
        transform: translateX(-50%);
        border: 7px solid transparent;
        border-top-color: #1e293b;
    }
    .help-balloon-trigger.is-active .help-balloon {
        display: block;
        opacity: 1;
        transform: translateX(-50%) scale(1);
        pointer-events: auto;
    }

    .code-block {
        background: #1e1e2e;
        color: #a6e3a1;
        border-radius: 0.75rem;
        padding: 1rem 1.25rem;
        font-family: 'Courier New', Courier, monospace;
        font-size: 0.75rem;
        line-height: 1.7;
        overflow-x: auto;
        white-space: pre;
    }
    .code-block .code-comment { color: #6c7086; }
    .code-block .code-keyword { color: #cba6f7; }
    .code-block .code-string { color: #a6e3a1; }
    .code-block .code-flag { color: #89b4fa; }
    .code-block .code-path { color: #f9e2af; }
    .code-block .code-output { color: #9399b2; }
    .code-block .code-danger { color: #f38ba8; }
    .code-block .code-prompt { color: #89dceb; }

    .cmd-card {
        transition: all 0.15s ease;
    }
    .cmd-card:hover {
        box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    }

    .danger-badge {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 2px 8px;
        border-radius: 9999px;
        font-size: 10px;
        font-weight: 600;
    }
</style>
@endpush

@section('content')
<div class="max-w-6xl mx-auto">

    {{-- ============================================================ --}}
    {{-- 히어로 배너 --}}
    {{-- ============================================================ --}}
    <div class="rounded-2xl overflow-hidden mb-8 shadow-lg" style="background: linear-gradient(135deg, #0c4a6e 0%, #0f172a 100%);">
        <div class="flex items-center" style="flex-wrap: wrap;">
            <div style="flex: 1 1 300px; padding: 2rem 2.5rem;">
                <div class="flex items-center gap-2 text-sm mb-2" style="color: #7dd3fc;">
                    <span>아카데미</span>
                    <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" /></svg>
                    <span style="color: #bae6fd;">Docker 명령어</span>
                </div>
                <h1 class="text-3xl font-bold mb-2" style="color: #ffffff;">Docker 명령어</h1>
                <p class="text-sm" style="color: #cbd5e1;">SAM 프로젝트 로컬 Docker 환경에서 반드시 알아야 할 명령어 — 실전 중심 가이드</p>
            </div>
            <div class="shrink-0" style="width: 240px; padding: 1.5rem;">
                <div class="text-center" style="font-size: 100px; line-height: 1;">
                    <span style="filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));">🐳</span>
                </div>
            </div>
        </div>
    </div>

    <div class="flex gap-8">
        {{-- ============================================================ --}}
        {{-- 좌측 고정 목차 (TOC) --}}
        {{-- ============================================================ --}}
        <nav class="hidden lg:block shrink-0" style="width: 220px;">
            <div class="sticky top-24">
                <div class="bg-blue-50 border border-blue-200 rounded-xl p-5">
                    <h2 class="font-semibold text-blue-800 mb-3 flex items-center gap-2 text-sm">
                        <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 10h16M4 14h16M4 18h16" /></svg>
                        목차
                    </h2>
                    <div class="space-y-0.5 text-xs">
                        <a href="#docker-check" class="block text-blue-700 hover:text-blue-900 py-1 font-medium">1. Docker 기본 확인</a>
                        <a href="#docker-ps" class="block text-blue-600 hover:text-blue-800 py-0.5 pl-3">docker ps</a>
                        <a href="#docker-images" class="block text-blue-600 hover:text-blue-800 py-0.5 pl-3">docker images</a>

                        <a href="#container-control" class="block text-blue-700 hover:text-blue-900 py-1 font-medium mt-2">2. 컨테이너 제어</a>
                        <a href="#start-stop" class="block text-blue-600 hover:text-blue-800 py-0.5 pl-3">start / stop / restart</a>

                        <a href="#container-exec" class="block text-blue-700 hover:text-blue-900 py-1 font-medium mt-2">3. 컨테이너 진입 & 실행</a>
                        <a href="#docker-exec" class="block text-blue-600 hover:text-blue-800 py-0.5 pl-3">docker exec</a>
                        <a href="#sam-patterns" class="block text-blue-600 hover:text-blue-800 py-0.5 pl-3">SAM 전용 패턴</a>

                        <a href="#container-logs" class="block text-blue-700 hover:text-blue-900 py-1 font-medium mt-2">4. 로그 확인</a>
                        <a href="#docker-logs" class="block text-blue-600 hover:text-blue-800 py-0.5 pl-3">docker logs</a>

                        <a href="#docker-compose" class="block text-blue-700 hover:text-blue-900 py-1 font-medium mt-2">5. Docker Compose</a>
                        <a href="#compose-commands" class="block text-blue-600 hover:text-blue-800 py-0.5 pl-3">주요 명령어</a>

                        <a href="#volume-network" class="block text-blue-700 hover:text-blue-900 py-1 font-medium mt-2">6. 볼륨 & 네트워크</a>
                        <a href="#volume-list" class="block text-blue-600 hover:text-blue-800 py-0.5 pl-3">볼륨 관리</a>
                        <a href="#network-list" class="block text-blue-600 hover:text-blue-800 py-0.5 pl-3">네트워크 관리</a>

                        <a href="#troubleshooting" class="block text-blue-700 hover:text-blue-900 py-1 font-medium mt-2">7. 트러블슈팅</a>
                        <a href="#common-issues" class="block text-blue-600 hover:text-blue-800 py-0.5 pl-3">자주 발생하는 문제</a>

                        <a href="#danger-zone" class="block text-blue-700 hover:text-blue-900 py-1 font-medium mt-2">8. 위험한 명령어</a>
                        <a href="#danger-commands" class="block text-blue-600 hover:text-blue-800 py-0.5 pl-3">절대 주의!</a>
                    </div>
                </div>
            </div>
        </nav>

        {{-- ============================================================ --}}
        {{-- 우측 콘텐츠 --}}
        {{-- ============================================================ --}}
        <div class="flex-1 min-w-0 space-y-10">

            {{-- 모바일 목차 --}}
            <div class="lg:hidden bg-blue-50 border border-blue-200 rounded-xl p-4 mb-6">
                <details>
                    <summary class="font-semibold text-blue-800 text-sm cursor-pointer flex items-center gap-2">
                        <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 10h16M4 14h16M4 18h16" /></svg>
                        목차 보기
                    </summary>
                    <nav class="mt-3 space-y-1 text-sm">
                        <a href="#docker-check" class="block text-blue-700 hover:text-blue-900 py-1">1. Docker 기본 확인</a>
                        <a href="#container-control" class="block text-blue-700 hover:text-blue-900 py-1">2. 컨테이너 제어</a>
                        <a href="#container-exec" class="block text-blue-700 hover:text-blue-900 py-1">3. 컨테이너 진입 & 실행</a>
                        <a href="#container-logs" class="block text-blue-700 hover:text-blue-900 py-1">4. 로그 확인</a>
                        <a href="#docker-compose" class="block text-blue-700 hover:text-blue-900 py-1">5. Docker Compose</a>
                        <a href="#volume-network" class="block text-blue-700 hover:text-blue-900 py-1">6. 볼륨 & 네트워크</a>
                        <a href="#troubleshooting" class="block text-blue-700 hover:text-blue-900 py-1">7. 트러블슈팅</a>
                        <a href="#danger-zone" class="block text-blue-700 hover:text-blue-900 py-1">8. 위험한 명령어</a>
                    </nav>
                </details>
            </div>

            {{-- ============================================================ --}}
            {{-- 1. Docker 기본 확인 --}}
            {{-- ============================================================ --}}
            <section id="docker-check" class="scroll-mt-20">
                <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                    <h2 class="text-xl font-bold text-gray-800 mb-6 flex items-center gap-3">
                        <span class="w-8 h-8 bg-sky-600 text-white rounded-lg flex items-center justify-center text-sm font-bold">1</span>
                        Docker 기본 확인
                    </h2>

                    <div id="docker-ps" class="scroll-mt-20 mb-8">
                        <h3 class="text-lg font-semibold text-gray-800 mb-3 flex items-center gap-2">
                            <span class="w-2 h-2 bg-sky-400 rounded-full"></span>
                            docker ps — 실행 중인 컨테이너 확인
                            <span class="help-balloon-trigger" onclick="toggleBalloon(this)">?<span class="help-balloon">가장 자주 쓰는 명령어. "지금 어떤 컨테이너가 돌아가고 있지?" 궁금할 때 사용한다.</span></span>
                        </h3>
                        <div class="bg-amber-50 rounded-lg p-4 border border-amber-100 mb-4">
                            <p class="font-semibold text-amber-800 mb-1">비유: 사무실 좌석 현황판</p>
                            <p class="text-xs text-amber-900 leading-relaxed">
                                사무실 출입구에 있는 좌석 현황판처럼, <code class="bg-amber-100 px-1.5 py-0.5 rounded text-xs">docker ps</code>는
                                <strong>지금 근무 중인(실행 중인) 컨테이너 목록</strong>을 보여준다.
                            </p>
                        </div>
                        <div class="space-y-3">
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="bg-sky-100 text-sky-800 text-xs font-bold px-2 py-0.5 rounded">기본</span>
                                    <span class="text-sm font-semibold text-gray-800">실행 중인 컨테이너만</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> ps
<span class="code-output">CONTAINER ID   IMAGE          STATUS          NAMES
a1b2c3d4       sam-mng        Up 2 hours      sam-mng-1
e5f6g7h8       sam-api        Up 2 hours      sam-api-1
i9j0k1l2       mysql:8.0      Up 2 hours      sam-mysql-1
m3n4o5p6       nginx:alpine   Up 2 hours      sam-nginx-1</span></div>
                            </div>
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="bg-purple-100 text-purple-800 text-xs font-bold px-2 py-0.5 rounded">응용</span>
                                    <span class="text-sm font-semibold text-gray-800">모든 컨테이너 (중지된 것 포함)</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> ps <span class="code-flag">-a</span>
<span class="code-comment"># -a = all. 중지된 컨테이너까지 전부 보여준다</span>
<span class="code-output">CONTAINER ID   IMAGE          STATUS                   NAMES
a1b2c3d4       sam-mng        Up 2 hours               sam-mng-1
q7r8s9t0       sam-react      Exited (0) 3 hours ago   sam-react-1</span></div>
                            </div>
                        </div>
                    </div>

                    <div id="docker-images" class="scroll-mt-20">
                        <h3 class="text-lg font-semibold text-gray-800 mb-3 flex items-center gap-2">
                            <span class="w-2 h-2 bg-sky-400 rounded-full"></span>
                            docker images — 설치된 이미지 목록
                            <span class="help-balloon-trigger" onclick="toggleBalloon(this)">?<span class="help-balloon">이미지는 컨테이너를 만들기 위한 "설계도"이다. 어떤 설계도가 설치되어 있는지 확인할 때 사용한다.</span></span>
                        </h3>
                        <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                            <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> images
<span class="code-output">REPOSITORY     TAG       IMAGE ID       SIZE
sam-mng        latest    abc123def      650MB
sam-api        latest    456ghi789      620MB
mysql          8.0       jkl012mno      580MB
nginx          alpine    pqr345stu      40MB</span></div>
                        </div>
                    </div>
                </div>
            </section>

            {{-- ============================================================ --}}
            {{-- 2. 컨테이너 제어 --}}
            {{-- ============================================================ --}}
            <section id="container-control" class="scroll-mt-20">
                <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                    <h2 class="text-xl font-bold text-gray-800 mb-6 flex items-center gap-3">
                        <span class="w-8 h-8 bg-sky-600 text-white rounded-lg flex items-center justify-center text-sm font-bold">2</span>
                        컨테이너 제어
                    </h2>

                    <div id="start-stop" class="scroll-mt-20">
                        <h3 class="text-lg font-semibold text-gray-800 mb-3 flex items-center gap-2">
                            <span class="w-2 h-2 bg-sky-400 rounded-full"></span>
                            start / stop / restart
                            <span class="help-balloon-trigger" onclick="toggleBalloon(this)">?<span class="help-balloon">컨테이너를 시작, 중지, 재시작하는 명령어. 전원 버튼을 누르는 것과 같다.</span></span>
                        </h3>
                        <div class="bg-amber-50 rounded-lg p-4 border border-amber-100 mb-4">
                            <p class="font-semibold text-amber-800 mb-1">비유: 가전제품 전원 관리</p>
                            <p class="text-xs text-amber-900 leading-relaxed">
                                <code class="bg-amber-100 px-1 rounded">stop</code>은 TV 끄기,
                                <code class="bg-amber-100 px-1 rounded">start</code>는 TV 켜기,
                                <code class="bg-amber-100 px-1 rounded">restart</code>는 TV를 <strong>껐다 다시 켜는 것</strong>이다.
                            </p>
                        </div>
                        <div class="space-y-3">
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="bg-green-100 text-green-800 text-xs font-bold px-2 py-0.5 rounded">시작</span>
                                    <span class="text-sm font-semibold text-gray-800">컨테이너 시작</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> start <span class="code-string">sam-api-1</span>
<span class="code-comment"># 중지된 컨테이너를 다시 시작</span></div>
                            </div>
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="bg-red-100 text-red-800 text-xs font-bold px-2 py-0.5 rounded">중지</span>
                                    <span class="text-sm font-semibold text-gray-800">컨테이너 중지</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> stop <span class="code-string">sam-mng-1</span>
<span class="code-comment"># 실행 중인 컨테이너를 안전하게 중지</span></div>
                            </div>
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="bg-amber-100 text-amber-800 text-xs font-bold px-2 py-0.5 rounded">재시작</span>
                                    <span class="text-sm font-semibold text-gray-800">컨테이너 재시작</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> restart <span class="code-string">sam-api-1</span>
<span class="code-comment"># stop + start를 한 번에. 설정 변경 후 자주 사용</span></div>
                            </div>
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="bg-purple-100 text-purple-800 text-xs font-bold px-2 py-0.5 rounded">응용</span>
                                    <span class="text-sm font-semibold text-gray-800">여러 컨테이너 한번에</span>
                                </div>
                                <div class="code-block"><span class="code-comment"># 여러 컨테이너를 한 번에 중지/시작/재시작</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker</span> stop <span class="code-string">sam-api-1 sam-mng-1</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker</span> start <span class="code-string">sam-api-1 sam-mng-1</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker</span> restart <span class="code-string">sam-api-1 sam-mng-1 sam-nginx-1</span></div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>

            {{-- ============================================================ --}}
            {{-- 3. 컨테이너 진입 & 실행 --}}
            {{-- ============================================================ --}}
            <section id="container-exec" class="scroll-mt-20">
                <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                    <h2 class="text-xl font-bold text-gray-800 mb-6 flex items-center gap-3">
                        <span class="w-8 h-8 bg-sky-600 text-white rounded-lg flex items-center justify-center text-sm font-bold">3</span>
                        컨테이너 진입 & 실행
                    </h2>

                    <div id="docker-exec" class="scroll-mt-20 mb-8">
                        <h3 class="text-lg font-semibold text-gray-800 mb-3 flex items-center gap-2">
                            <span class="w-2 h-2 bg-sky-400 rounded-full"></span>
                            docker exec — 컨테이너 안에서 명령 실행
                            <span class="help-balloon-trigger" onclick="toggleBalloon(this)">?<span class="help-balloon">실행 중인 컨테이너 "안으로 들어가서" 명령어를 실행한다. SAM에서 가장 많이 쓰는 핵심 명령어이다.</span></span>
                        </h3>
                        <div class="bg-amber-50 rounded-lg p-4 border border-amber-100 mb-4">
                            <p class="font-semibold text-amber-800 mb-1">비유: 회의실에 들어가서 지시하기</p>
                            <p class="text-xs text-amber-900 leading-relaxed">
                                <code class="bg-amber-100 px-1.5 py-0.5 rounded text-xs">docker exec</code>는
                                <strong>컨테이너라는 방 안에 들어가서 명령을 전달</strong>하는 것이다.
                                내 PC(WSL)에는 PHP가 없지만, 컨테이너 안에는 있으므로 exec로 실행한다.
                            </p>
                        </div>
                        <div class="space-y-3">
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="bg-sky-100 text-sky-800 text-xs font-bold px-2 py-0.5 rounded">기본</span>
                                    <span class="text-sm font-semibold text-gray-800">명령어 한 줄 실행</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> exec <span class="code-string">sam-api-1</span> <span class="code-path">php artisan migrate</span>
<span class="code-comment"># sam-api-1 컨테이너 안에서 php artisan migrate 실행</span></div>
                            </div>
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="bg-purple-100 text-purple-800 text-xs font-bold px-2 py-0.5 rounded">대화형</span>
                                    <span class="text-sm font-semibold text-gray-800">컨테이너 안에 직접 들어가기 (-it)</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> exec <span class="code-flag">-it</span> <span class="code-string">sam-api-1</span> <span class="code-path">bash</span>
<span class="code-comment"># -i = interactive (키보드 입력 가능)</span>
<span class="code-comment"># -t = tty (터미널 화면 할당)</span>
<span class="code-comment"># bash = 쉘 프로그램 실행</span>
<span class="code-output">root@a1b2c3d4:/var/www/html#</span> <span class="code-comment">← 컨테이너 안에 들어온 상태</span>
<span class="code-output">root@a1b2c3d4:/var/www/html#</span> exit  <span class="code-comment">← exit로 빠져나오기</span></div>
                            </div>
                        </div>

                        <div class="bg-blue-50 rounded-lg p-4 border border-blue-100 mt-4">
                            <p class="font-semibold text-blue-800 mb-1">-it 언제 쓰나?</p>
                            <div class="text-xs text-blue-900 space-y-1">
                                <p><strong>쓰지 않아도 되는 경우:</strong> 명령어 하나만 실행하고 끝날 때 <code class="bg-blue-100 px-1 rounded">docker exec sam-api-1 php artisan migrate</code></p>
                                <p><strong>써야 하는 경우:</strong> 컨테이너 안에서 여러 명령을 연속으로 할 때, 또는 <code class="bg-blue-100 px-1 rounded">tinker</code>처럼 대화형 프로그램을 실행할 때</p>
                            </div>
                        </div>
                    </div>

                    <div id="sam-patterns" class="scroll-mt-20">
                        <h3 class="text-lg font-semibold text-gray-800 mb-3 flex items-center gap-2">
                            <span class="w-2 h-2 bg-sky-400 rounded-full"></span>
                            SAM 프로젝트 전용 명령어 패턴
                        </h3>
                        <div class="bg-indigo-50 border-2 border-indigo-300 rounded-xl p-5 mb-4">
                            <div class="flex items-start gap-3">
                                <span class="w-8 h-8 bg-indigo-500 text-white rounded-lg flex items-center justify-center text-sm font-bold shrink-0">!</span>
                                <div>
                                    <p class="font-bold text-indigo-900 mb-1">핵심: 마이그레이션은 반드시 API 컨테이너에서!</p>
                                    <p class="text-xs text-indigo-700">MNG에서 마이그레이션 실행 금지. 모든 DB 관련 작업은 <code class="bg-indigo-100 px-1 rounded">sam-api-1</code>에서만 실행한다.</p>
                                </div>
                            </div>
                        </div>
                        <div class="overflow-x-auto">
                            <table class="w-full text-xs border-collapse">
                                <thead>
                                    <tr class="bg-gray-100">
                                        <th class="text-left p-3 border border-gray-200 font-semibold text-gray-700" style="min-width: 120px;">목적</th>
                                        <th class="text-left p-3 border border-gray-200 font-semibold text-gray-700">명령어</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td class="p-3 border border-gray-200 font-medium text-gray-800">마이그레이션</td>
                                        <td class="p-3 border border-gray-200"><code class="bg-gray-100 px-1.5 py-0.5 rounded text-xs">docker exec sam-api-1 php artisan migrate</code></td>
                                    </tr>
                                    <tr class="bg-gray-50">
                                        <td class="p-3 border border-gray-200 font-medium text-gray-800">캐시 클리어 (MNG)</td>
                                        <td class="p-3 border border-gray-200"><code class="bg-gray-100 px-1.5 py-0.5 rounded text-xs">docker exec sam-mng-1 php artisan cache:clear</code></td>
                                    </tr>
                                    <tr>
                                        <td class="p-3 border border-gray-200 font-medium text-gray-800">캐시 클리어 (API)</td>
                                        <td class="p-3 border border-gray-200"><code class="bg-gray-100 px-1.5 py-0.5 rounded text-xs">docker exec sam-api-1 php artisan cache:clear</code></td>
                                    </tr>
                                    <tr class="bg-gray-50">
                                        <td class="p-3 border border-gray-200 font-medium text-gray-800">설정 초기화</td>
                                        <td class="p-3 border border-gray-200"><code class="bg-gray-100 px-1.5 py-0.5 rounded text-xs">docker exec sam-api-1 php artisan config:clear</code></td>
                                    </tr>
                                    <tr>
                                        <td class="p-3 border border-gray-200 font-medium text-gray-800">Composer 설치</td>
                                        <td class="p-3 border border-gray-200"><code class="bg-gray-100 px-1.5 py-0.5 rounded text-xs">docker exec sam-api-1 composer install</code></td>
                                    </tr>
                                    <tr class="bg-gray-50">
                                        <td class="p-3 border border-gray-200 font-medium text-gray-800">Tinker (대화형)</td>
                                        <td class="p-3 border border-gray-200"><code class="bg-gray-100 px-1.5 py-0.5 rounded text-xs">docker exec -it sam-api-1 php artisan tinker</code></td>
                                    </tr>
                                    <tr>
                                        <td class="p-3 border border-gray-200 font-medium text-gray-800">MySQL 접속</td>
                                        <td class="p-3 border border-gray-200"><code class="bg-gray-100 px-1.5 py-0.5 rounded text-xs">docker exec -it sam-mysql-1 mysql -u root -proot samdb</code></td>
                                    </tr>
                                    <tr class="bg-gray-50">
                                        <td class="p-3 border border-gray-200 font-medium text-gray-800">Pint 포맷팅 (MNG)</td>
                                        <td class="p-3 border border-gray-200"><code class="bg-gray-100 px-1.5 py-0.5 rounded text-xs">docker exec sam-mng-1 ./vendor/bin/pint</code></td>
                                    </tr>
                                    <tr>
                                        <td class="p-3 border border-gray-200 font-medium text-gray-800">라우트 목록</td>
                                        <td class="p-3 border border-gray-200"><code class="bg-gray-100 px-1.5 py-0.5 rounded text-xs">docker exec sam-mng-1 php artisan route:list</code></td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>

                        <div class="mt-4 grid grid-cols-1 md:grid-cols-3 gap-3 text-xs">
                            <div class="bg-sky-50 rounded-lg p-3 border border-sky-200 text-center">
                                <p class="font-bold text-sky-800 mb-1">sam-api-1</p>
                                <p class="text-sky-700">API 서버 (Laravel)<br>마이그레이션, 시더, API</p>
                            </div>
                            <div class="bg-emerald-50 rounded-lg p-3 border border-emerald-200 text-center">
                                <p class="font-bold text-emerald-800 mb-1">sam-mng-1</p>
                                <p class="text-emerald-700">관리자 웹 (Laravel)<br>뷰, 라우트, 포맷팅</p>
                            </div>
                            <div class="bg-amber-50 rounded-lg p-3 border border-amber-200 text-center">
                                <p class="font-bold text-amber-800 mb-1">sam-mysql-1</p>
                                <p class="text-amber-700">MySQL 데이터베이스<br>DB 접속, 쿼리 실행</p>
                            </div>
                        </div>
                    </div>
                </div>
            </section>

            {{-- ============================================================ --}}
            {{-- 4. 로그 확인 --}}
            {{-- ============================================================ --}}
            <section id="container-logs" class="scroll-mt-20">
                <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                    <h2 class="text-xl font-bold text-gray-800 mb-6 flex items-center gap-3">
                        <span class="w-8 h-8 bg-sky-600 text-white rounded-lg flex items-center justify-center text-sm font-bold">4</span>
                        로그 확인
                    </h2>

                    <div id="docker-logs" class="scroll-mt-20">
                        <h3 class="text-lg font-semibold text-gray-800 mb-3 flex items-center gap-2">
                            <span class="w-2 h-2 bg-sky-400 rounded-full"></span>
                            docker logs — 컨테이너 로그 보기
                            <span class="help-balloon-trigger" onclick="toggleBalloon(this)">?<span class="help-balloon">컨테이너가 출력하는 모든 메시지(에러, 접속 기록 등)를 확인할 수 있다. 오류 원인을 찾을 때 필수.</span></span>
                        </h3>
                        <div class="space-y-3">
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="bg-sky-100 text-sky-800 text-xs font-bold px-2 py-0.5 rounded">기본</span>
                                    <span class="text-sm font-semibold text-gray-800">전체 로그 보기</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> logs <span class="code-string">sam-api-1</span>
<span class="code-comment"># 컨테이너 시작부터 지금까지의 모든 로그 출력</span></div>
                            </div>
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="bg-purple-100 text-purple-800 text-xs font-bold px-2 py-0.5 rounded">응용</span>
                                    <span class="text-sm font-semibold text-gray-800">최근 N줄만 보기 (--tail)</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> logs <span class="code-flag">--tail 50</span> <span class="code-string">sam-nginx-1</span>
<span class="code-comment"># 최근 50줄만 출력. 로그가 많을 때 유용</span></div>
                            </div>
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="bg-green-100 text-green-800 text-xs font-bold px-2 py-0.5 rounded">실시간</span>
                                    <span class="text-sm font-semibold text-gray-800">실시간 로그 추적 (-f)</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> logs <span class="code-flag">-f</span> <span class="code-string">sam-api-1</span>
<span class="code-comment"># -f = follow. 새 로그가 생기면 실시간으로 표시</span>
<span class="code-comment"># Ctrl + C 로 종료</span></div>
                            </div>
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="bg-amber-100 text-amber-800 text-xs font-bold px-2 py-0.5 rounded">시간 필터</span>
                                    <span class="text-sm font-semibold text-gray-800">특정 시간 이후 로그 (--since)</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> logs <span class="code-flag">--since 30m</span> <span class="code-string">sam-api-1</span>
<span class="code-comment"># 최근 30분 이내의 로그만 출력</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker</span> logs <span class="code-flag">--since 2h</span> <span class="code-string">sam-mng-1</span>
<span class="code-comment"># 최근 2시간 이내의 로그만 출력</span></div>
                            </div>
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="bg-purple-100 text-purple-800 text-xs font-bold px-2 py-0.5 rounded">조합</span>
                                    <span class="text-sm font-semibold text-gray-800">실무에서 가장 많이 쓰는 조합</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> logs <span class="code-flag">--tail 100 -f</span> <span class="code-string">sam-api-1</span>
<span class="code-comment"># 최근 100줄 출력 후 실시간 추적. 실무 디버깅의 기본!</span></div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>

            {{-- ============================================================ --}}
            {{-- 5. Docker Compose --}}
            {{-- ============================================================ --}}
            <section id="docker-compose" class="scroll-mt-20">
                <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                    <h2 class="text-xl font-bold text-gray-800 mb-6 flex items-center gap-3">
                        <span class="w-8 h-8 bg-sky-600 text-white rounded-lg flex items-center justify-center text-sm font-bold">5</span>
                        Docker Compose
                    </h2>

                    <div id="compose-commands" class="scroll-mt-20">
                        <h3 class="text-lg font-semibold text-gray-800 mb-3 flex items-center gap-2">
                            <span class="w-2 h-2 bg-sky-400 rounded-full"></span>
                            주요 명령어
                            <span class="help-balloon-trigger" onclick="toggleBalloon(this)">?<span class="help-balloon">Docker Compose는 여러 컨테이너를 한 번에 관리하는 도구이다. docker-compose.yml 파일에 모든 설정이 정의되어 있다.</span></span>
                        </h3>
                        <div class="bg-amber-50 rounded-lg p-4 border border-amber-100 mb-4">
                            <p class="font-semibold text-amber-800 mb-1">비유: 오케스트라 지휘자</p>
                            <p class="text-xs text-amber-900 leading-relaxed">
                                Docker Compose는 <strong>오케스트라 지휘자</strong>와 같다. 지휘자가 악보(docker-compose.yml) 하나로
                                모든 악기(컨테이너)를 동시에 시작·중지·조율하듯, Compose는 여러 컨테이너를 <strong>한 번에 관리</strong>한다.
                            </p>
                        </div>

                        <div class="bg-blue-50 rounded-lg p-4 border border-blue-100 mb-4">
                            <p class="font-semibold text-blue-800 mb-1">SAM의 docker-compose.yml 위치</p>
                            <p class="text-xs text-blue-900"><code class="bg-blue-100 px-1.5 py-0.5 rounded">/home/aweso/sam/docker-compose.yml</code></p>
                            <p class="text-xs text-blue-700 mt-1">모든 <code class="bg-blue-100 px-1 rounded">docker compose</code> 명령어는 이 파일이 있는 디렉토리(<code class="bg-blue-100 px-1 rounded">/home/aweso/sam</code>)에서 실행해야 한다.</p>
                        </div>

                        <div class="space-y-3">
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="bg-green-100 text-green-800 text-xs font-bold px-2 py-0.5 rounded">시작</span>
                                    <span class="text-sm font-semibold text-gray-800">모든 컨테이너 시작</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">cd</span> <span class="code-path">/home/aweso/sam</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker compose</span> up <span class="code-flag">-d</span>
<span class="code-comment"># -d = detached (백그라운드 실행)</span>
<span class="code-comment"># docker-compose.yml에 정의된 모든 서비스를 한 번에 시작</span></div>
                            </div>
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="bg-red-100 text-red-800 text-xs font-bold px-2 py-0.5 rounded">종료</span>
                                    <span class="text-sm font-semibold text-gray-800">모든 컨테이너 종료</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker compose</span> down
<span class="code-comment"># 모든 컨테이너를 중지하고 제거</span>
<span class="code-comment"># 볼륨(DB 데이터)은 유지됨!</span></div>
                            </div>
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="bg-sky-100 text-sky-800 text-xs font-bold px-2 py-0.5 rounded">상태</span>
                                    <span class="text-sm font-semibold text-gray-800">서비스 상태 확인</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker compose</span> ps
<span class="code-output">NAME           SERVICE   STATUS    PORTS
sam-api-1      api       running   9000/tcp
sam-mng-1      mng       running   9000/tcp
sam-mysql-1    mysql     running   3306/tcp
sam-nginx-1    nginx     running   0.0.0.0:80->80/tcp</span></div>
                            </div>
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="bg-amber-100 text-amber-800 text-xs font-bold px-2 py-0.5 rounded">로그</span>
                                    <span class="text-sm font-semibold text-gray-800">전체 서비스 로그 보기</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker compose</span> logs <span class="code-flag">-f</span>
<span class="code-comment"># 모든 서비스의 로그를 한 화면에서 실시간 추적</span>

<span class="code-prompt">$</span> <span class="code-keyword">docker compose</span> logs <span class="code-flag">-f</span> <span class="code-string">api mng</span>
<span class="code-comment"># 특정 서비스만 골라서 로그 확인</span></div>
                            </div>
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="bg-purple-100 text-purple-800 text-xs font-bold px-2 py-0.5 rounded">재시작</span>
                                    <span class="text-sm font-semibold text-gray-800">특정 서비스만 재시작</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker compose</span> restart <span class="code-string">api</span>
<span class="code-comment"># api 서비스만 재시작 (다른 서비스는 그대로)</span>

<span class="code-prompt">$</span> <span class="code-keyword">docker compose</span> restart
<span class="code-comment"># 모든 서비스 재시작</span></div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>

            {{-- ============================================================ --}}
            {{-- 6. 볼륨 & 네트워크 --}}
            {{-- ============================================================ --}}
            <section id="volume-network" class="scroll-mt-20">
                <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                    <h2 class="text-xl font-bold text-gray-800 mb-6 flex items-center gap-3">
                        <span class="w-8 h-8 bg-sky-600 text-white rounded-lg flex items-center justify-center text-sm font-bold">6</span>
                        볼륨 & 네트워크
                    </h2>

                    <div id="volume-list" class="scroll-mt-20 mb-8">
                        <h3 class="text-lg font-semibold text-gray-800 mb-3 flex items-center gap-2">
                            <span class="w-2 h-2 bg-sky-400 rounded-full"></span>
                            볼륨 관리
                            <span class="help-balloon-trigger" onclick="toggleBalloon(this)">?<span class="help-balloon">볼륨은 컨테이너 데이터를 영구 저장하는 공간이다. 컨테이너를 삭제해도 볼륨에 저장된 데이터(DB 등)는 남아 있다.</span></span>
                        </h3>
                        <div class="bg-amber-50 rounded-lg p-4 border border-amber-100 mb-4">
                            <p class="font-semibold text-amber-800 mb-1">비유: USB 외장하드</p>
                            <p class="text-xs text-amber-900 leading-relaxed">
                                컨테이너가 컴퓨터라면, 볼륨은 <strong>USB 외장하드</strong>이다.
                                컴퓨터(컨테이너)를 바꿔도 외장하드(볼륨)에 저장한 데이터는 그대로 남아 있다.
                            </p>
                        </div>
                        <div class="space-y-3">
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> volume ls
<span class="code-comment"># 생성된 볼륨 목록 조회</span>
<span class="code-output">DRIVER    VOLUME NAME
local     sam_mysql-data
local     sam_phpmyadmin-data</span></div>
                            </div>
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> volume inspect <span class="code-string">sam_mysql-data</span>
<span class="code-comment"># 볼륨의 상세 정보(저장 위치 등) 확인</span></div>
                            </div>
                        </div>

                        <div class="mt-4 overflow-x-auto">
                            <table class="w-full text-xs border-collapse">
                                <thead>
                                    <tr class="bg-gray-100">
                                        <th class="text-left p-3 border border-gray-200 font-semibold text-gray-700">볼륨 이름</th>
                                        <th class="text-left p-3 border border-gray-200 font-semibold text-gray-700">용도</th>
                                        <th class="text-left p-3 border border-gray-200 font-semibold text-gray-700">삭제 시 영향</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td class="p-3 border border-gray-200 font-mono">sam_mysql-data</td>
                                        <td class="p-3 border border-gray-200">MySQL 데이터 저장</td>
                                        <td class="p-3 border border-gray-200"><span class="danger-badge bg-red-100 text-red-800">DB 데이터 전체 삭제!</span></td>
                                    </tr>
                                    <tr class="bg-gray-50">
                                        <td class="p-3 border border-gray-200 font-mono">sam_phpmyadmin-data</td>
                                        <td class="p-3 border border-gray-200">phpMyAdmin 세션</td>
                                        <td class="p-3 border border-gray-200"><span class="text-gray-500">영향 미미</span></td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>

                    <div id="network-list" class="scroll-mt-20">
                        <h3 class="text-lg font-semibold text-gray-800 mb-3 flex items-center gap-2">
                            <span class="w-2 h-2 bg-sky-400 rounded-full"></span>
                            네트워크 관리
                            <span class="help-balloon-trigger" onclick="toggleBalloon(this)">?<span class="help-balloon">Docker 네트워크는 컨테이너들이 서로 통신하는 가상 네트워크이다. SAM의 모든 컨테이너는 samnet이라는 하나의 네트워크에 연결되어 있다.</span></span>
                        </h3>
                        <div class="space-y-3">
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> network ls
<span class="code-comment"># Docker 네트워크 목록 조회</span>
<span class="code-output">NETWORK ID     NAME      DRIVER    SCOPE
abc123def      samnet    bridge    local</span></div>
                            </div>
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border border-gray-200">
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> network inspect <span class="code-string">samnet</span>
<span class="code-comment"># samnet에 연결된 컨테이너 목록과 IP 주소 확인</span></div>
                            </div>
                        </div>
                        <div class="bg-blue-50 rounded-lg p-4 border border-blue-100 mt-4">
                            <p class="font-semibold text-blue-800 mb-1">SAM 네트워크 구조</p>
                            <p class="text-xs text-blue-900">
                                모든 SAM 컨테이너는 <code class="bg-blue-100 px-1 rounded">samnet</code> 브리지 네트워크에 연결되어 있다.
                                같은 네트워크 안에서는 <strong>컨테이너 이름으로 서로 접근</strong>할 수 있다.
                                예: API 컨테이너가 MySQL에 접속할 때 <code class="bg-blue-100 px-1 rounded">sam-mysql-1:3306</code>으로 연결한다.
                            </p>
                        </div>
                    </div>
                </div>
            </section>

            {{-- ============================================================ --}}
            {{-- 7. 트러블슈팅 --}}
            {{-- ============================================================ --}}
            <section id="troubleshooting" class="scroll-mt-20">
                <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                    <h2 class="text-xl font-bold text-gray-800 mb-6 flex items-center gap-3">
                        <span class="w-8 h-8 bg-sky-600 text-white rounded-lg flex items-center justify-center text-sm font-bold">7</span>
                        트러블슈팅
                    </h2>

                    <div id="common-issues" class="scroll-mt-20">
                        <h3 class="text-lg font-semibold text-gray-800 mb-3 flex items-center gap-2">
                            <span class="w-2 h-2 bg-sky-400 rounded-full"></span>
                            자주 발생하는 문제 & 해결 방법
                        </h3>

                        {{-- 문제 1 --}}
                        <div class="mb-4">
                            <div class="cmd-card bg-red-50 rounded-lg p-4 border border-red-200">
                                <p class="font-bold text-red-800 mb-2">문제 1: "사이트에 연결할 수 없음" (mng.sam.kr 접속 불가)</p>
                                <p class="text-xs text-red-700 mb-3">원인: Docker 컨테이너가 실행되지 않았거나 중지된 상태</p>
                                <p class="text-xs font-semibold text-gray-800 mb-1">해결:</p>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> ps                  <span class="code-comment"># 실행 중인 컨테이너 확인</span>
<span class="code-prompt">$</span> <span class="code-keyword">cd</span> <span class="code-path">/home/aweso/sam</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker compose</span> up <span class="code-flag">-d</span>    <span class="code-comment"># 모든 서비스 시작</span></div>
                            </div>
                        </div>

                        {{-- 문제 2 --}}
                        <div class="mb-4">
                            <div class="cmd-card bg-red-50 rounded-lg p-4 border border-red-200">
                                <p class="font-bold text-red-800 mb-2">문제 2: "500 Server Error" (서버 내부 오류)</p>
                                <p class="text-xs text-red-700 mb-3">원인: PHP 오류, .env 설정 문제, 캐시 문제 등</p>
                                <p class="text-xs font-semibold text-gray-800 mb-1">해결:</p>
                                <div class="code-block"><span class="code-comment"># 1. 로그 확인 (원인 파악)</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker</span> logs <span class="code-flag">--tail 50</span> <span class="code-string">sam-mng-1</span>

<span class="code-comment"># 2. 캐시 전부 클리어</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker</span> exec <span class="code-string">sam-mng-1</span> <span class="code-path">php artisan config:clear</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker</span> exec <span class="code-string">sam-mng-1</span> <span class="code-path">php artisan cache:clear</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker</span> exec <span class="code-string">sam-mng-1</span> <span class="code-path">php artisan view:clear</span></div>
                            </div>
                        </div>

                        {{-- 문제 3 --}}
                        <div class="mb-4">
                            <div class="cmd-card bg-red-50 rounded-lg p-4 border border-red-200">
                                <p class="font-bold text-red-800 mb-2">문제 3: "Class not found" (클래스를 찾을 수 없음)</p>
                                <p class="text-xs text-red-700 mb-3">원인: Composer autoload가 갱신되지 않았거나, 새 패키지 설치가 필요</p>
                                <p class="text-xs font-semibold text-gray-800 mb-1">해결:</p>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> exec <span class="code-string">sam-mng-1</span> <span class="code-path">composer dump-autoload</span>
<span class="code-comment"># 또는 composer install로 전체 의존성 재설치</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker</span> exec <span class="code-string">sam-mng-1</span> <span class="code-path">composer install</span></div>
                            </div>
                        </div>

                        {{-- 문제 4 --}}
                        <div class="mb-4">
                            <div class="cmd-card bg-red-50 rounded-lg p-4 border border-red-200">
                                <p class="font-bold text-red-800 mb-2">문제 4: "Connection refused" (MySQL 접속 실패)</p>
                                <p class="text-xs text-red-700 mb-3">원인: MySQL 컨테이너가 아직 시작되지 않았거나, .env의 DB 설정이 잘못됨</p>
                                <p class="text-xs font-semibold text-gray-800 mb-1">해결:</p>
                                <div class="code-block"><span class="code-comment"># 1. MySQL 컨테이너 상태 확인</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker</span> ps <span class="code-flag">-a</span> | grep mysql
<span class="code-comment"># STATUS가 "Up"인지 확인</span>

<span class="code-comment"># 2. MySQL이 중지되어 있다면 시작</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker</span> start <span class="code-string">sam-mysql-1</span>

<span class="code-comment"># 3. MySQL 접속 테스트</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker</span> exec <span class="code-flag">-it</span> <span class="code-string">sam-mysql-1</span> <span class="code-path">mysql -u root -proot samdb</span></div>
                            </div>
                        </div>

                        {{-- 문제 5 --}}
                        <div class="mb-6">
                            <div class="cmd-card bg-red-50 rounded-lg p-4 border border-red-200">
                                <p class="font-bold text-red-800 mb-2">문제 5: "Permission denied" (권한 오류)</p>
                                <p class="text-xs text-red-700 mb-3">원인: storage, bootstrap/cache 디렉토리의 쓰기 권한이 없음</p>
                                <p class="text-xs font-semibold text-gray-800 mb-1">해결:</p>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> exec <span class="code-string">sam-mng-1</span> <span class="code-path">chmod -R 777 storage bootstrap/cache</span>
<span class="code-comment"># storage와 bootstrap/cache에 모든 권한 부여</span></div>
                            </div>
                        </div>

                        {{-- SAM 캐시 클리어 총정리 --}}
                        <div class="bg-emerald-50 border-2 border-emerald-300 rounded-xl p-5">
                            <h4 class="font-bold text-emerald-900 mb-3 flex items-center gap-2">
                                <span class="text-lg">🧹</span> SAM 캐시 클리어 총정리 (외우면 좋은 명령어)
                            </h4>
                            <div class="code-block"><span class="code-comment"># === MNG 캐시 클리어 ===</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker</span> exec <span class="code-string">sam-mng-1</span> <span class="code-path">php artisan config:clear</span>   <span class="code-comment"># 설정 캐시</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker</span> exec <span class="code-string">sam-mng-1</span> <span class="code-path">php artisan cache:clear</span>    <span class="code-comment"># 앱 캐시</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker</span> exec <span class="code-string">sam-mng-1</span> <span class="code-path">php artisan view:clear</span>     <span class="code-comment"># 뷰 캐시</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker</span> exec <span class="code-string">sam-mng-1</span> <span class="code-path">php artisan route:clear</span>    <span class="code-comment"># 라우트 캐시</span>

<span class="code-comment"># === API 캐시 클리어 ===</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker</span> exec <span class="code-string">sam-api-1</span> <span class="code-path">php artisan config:clear</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker</span> exec <span class="code-string">sam-api-1</span> <span class="code-path">php artisan cache:clear</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker</span> exec <span class="code-string">sam-api-1</span> <span class="code-path">php artisan view:clear</span>
<span class="code-prompt">$</span> <span class="code-keyword">docker</span> exec <span class="code-string">sam-api-1</span> <span class="code-path">php artisan route:clear</span></div>
                            <p class="text-xs text-emerald-700 mt-2">
                                <strong>팁:</strong> .env 파일을 수정했다면 반드시 <code class="bg-emerald-100 px-1 rounded">config:clear</code>를 실행해야 변경이 적용된다.
                            </p>
                        </div>
                    </div>
                </div>
            </section>

            {{-- ============================================================ --}}
            {{-- 8. 위험한 명령어 --}}
            {{-- ============================================================ --}}
            <section id="danger-zone" class="scroll-mt-20">
                <div class="bg-white rounded-xl shadow-sm border border-red-200 p-6">
                    <h2 class="text-xl font-bold text-red-700 mb-6 flex items-center gap-3">
                        <span class="w-8 h-8 bg-red-600 text-white rounded-lg flex items-center justify-center text-sm font-bold">8</span>
                        위험한 명령어
                    </h2>

                    <div id="danger-commands" class="scroll-mt-20">
                        <div class="bg-red-50 border-2 border-red-300 rounded-xl p-5 mb-6">
                            <div class="flex items-start gap-3">
                                <span class="w-8 h-8 bg-red-500 text-white rounded-lg flex items-center justify-center text-sm font-bold shrink-0">!</span>
                                <div>
                                    <p class="font-bold text-red-900 mb-1">경고: 아래 명령어는 데이터 손실을 유발할 수 있다</p>
                                    <p class="text-xs text-red-700">
                                        의미를 정확히 이해하지 않은 채 실행하면 <strong>DB 데이터 전체 삭제, 이미지 삭제 등 돌이킬 수 없는 피해</strong>가 발생할 수 있다.
                                        반드시 팀장이나 담당 개발자에게 확인 후 실행하자.
                                    </p>
                                </div>
                            </div>
                        </div>

                        <div class="space-y-4">
                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border-2 border-red-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="danger-badge bg-red-100 text-red-800">위험도 ★★★</span>
                                    <span class="text-sm font-bold text-gray-800">docker compose down -v</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker compose</span> down <span class="code-danger">-v</span>
<span class="code-comment"># -v = volumes. 컨테이너뿐만 아니라 볼륨(DB 데이터)까지 전부 삭제!</span>
<span class="code-comment"># MySQL 데이터가 완전히 사라진다. 절대 함부로 실행하지 말 것!</span></div>
                                <p class="text-xs text-red-700 mt-2">
                                    <strong>안전한 대안:</strong> <code class="bg-red-100 px-1 rounded">docker compose down</code> (-v 없이) — 볼륨은 유지하면서 컨테이너만 종료
                                </p>
                            </div>

                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border-2 border-red-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="danger-badge bg-red-100 text-red-800">위험도 ★★★</span>
                                    <span class="text-sm font-bold text-gray-800">docker system prune -a</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> system prune <span class="code-danger">-a</span>
<span class="code-comment"># 사용하지 않는 모든 이미지, 네트워크, 컨테이너를 일괄 삭제</span>
<span class="code-comment"># SAM 이미지까지 삭제되어 docker compose up 시 처음부터 빌드해야 함</span></div>
                                <p class="text-xs text-red-700 mt-2">
                                    <strong>디스크 공간이 부족하다면:</strong> <code class="bg-red-100 px-1 rounded">docker image prune</code> — 안 쓰는 이미지만 선별 삭제
                                </p>
                            </div>

                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border-2 border-red-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="danger-badge bg-amber-100 text-amber-800">위험도 ★★</span>
                                    <span class="text-sm font-bold text-gray-800">docker rm -f</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> rm <span class="code-danger">-f</span> <span class="code-string">sam-api-1</span>
<span class="code-comment"># -f = force. 실행 중인 컨테이너를 강제로 삭제</span>
<span class="code-comment"># 정상적인 종료 절차 없이 즉시 제거됨</span></div>
                                <p class="text-xs text-red-700 mt-2">
                                    <strong>안전한 대안:</strong> <code class="bg-amber-100 px-1 rounded">docker stop sam-api-1</code> — 먼저 안전하게 중지
                                </p>
                            </div>

                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border-2 border-red-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="danger-badge bg-amber-100 text-amber-800">위험도 ★★</span>
                                    <span class="text-sm font-bold text-gray-800">docker volume rm</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> volume rm <span class="code-danger">sam_mysql-data</span>
<span class="code-comment"># MySQL 데이터 볼륨 삭제 = DB 데이터 완전 손실!</span>
<span class="code-comment"># 관련 컨테이너가 중지된 상태에서만 삭제 가능</span></div>
                                <p class="text-xs text-red-700 mt-2">
                                    <strong>볼륨 삭제 전 반드시:</strong> <code class="bg-red-100 px-1 rounded">docker exec -it sam-mysql-1 mysqldump ...</code>로 백업 먼저!
                                </p>
                            </div>

                            <div class="cmd-card bg-gray-50 rounded-lg p-4 border-2 border-red-200">
                                <div class="flex items-center gap-2 mb-2">
                                    <span class="danger-badge bg-amber-100 text-amber-800">위험도 ★★</span>
                                    <span class="text-sm font-bold text-gray-800">docker rmi</span>
                                </div>
                                <div class="code-block"><span class="code-prompt">$</span> <span class="code-keyword">docker</span> rmi <span class="code-danger">sam-mng</span>
<span class="code-comment"># SAM MNG 이미지 삭제. 다시 빌드하는 데 시간이 소요됨</span></div>
                            </div>
                        </div>

                        {{-- 안전 체크리스트 --}}
                        <div class="bg-green-50 border border-green-200 rounded-xl p-5 mt-6">
                            <h4 class="font-bold text-green-900 mb-3 flex items-center gap-2">
                                <span class="text-lg">✅</span> Docker 사용 시 안전 수칙
                            </h4>
                            <ul class="text-xs text-green-800 space-y-2">
                                <li class="flex items-start gap-2">
                                    <span class="text-green-500 font-bold mt-0.5">1.</span>
                                    <span><code class="bg-green-100 px-1 rounded">-v</code>, <code class="bg-green-100 px-1 rounded">-f</code>, <code class="bg-green-100 px-1 rounded">prune</code> 플래그가 보이면 한 번 더 생각하기</span>
                                </li>
                                <li class="flex items-start gap-2">
                                    <span class="text-green-500 font-bold mt-0.5">2.</span>
                                    <span>볼륨 삭제 전 반드시 DB 백업</span>
                                </li>
                                <li class="flex items-start gap-2">
                                    <span class="text-green-500 font-bold mt-0.5">3.</span>
                                    <span><code class="bg-green-100 px-1 rounded">docker compose down</code>은 안전, <code class="bg-green-100 px-1 rounded">docker compose down -v</code>는 위험</span>
                                </li>
                                <li class="flex items-start gap-2">
                                    <span class="text-green-500 font-bold mt-0.5">4.</span>
                                    <span>모르는 명령어는 팀장에게 확인 후 실행</span>
                                </li>
                                <li class="flex items-start gap-2">
                                    <span class="text-green-500 font-bold mt-0.5">5.</span>
                                    <span><code class="bg-green-100 px-1 rounded">docker ps</code>로 현재 상태를 먼저 확인하는 습관 기르기</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </section>

        </div>
    </div>
</div>

{{-- Lightbox --}}
<div id="lightbox" onclick="closeLightbox()">
    <img id="lightbox-img" src="" alt="">
</div>

@include('components.academy-glossary', ['domain' => 'docker-commands'])
@endsection

@push('scripts')
<script>
(function() {
    // 도움말 풍선 토글
    window.toggleBalloon = function(el) {
        var wasActive = el.classList.contains('is-active');
        document.querySelectorAll('.help-balloon-trigger.is-active').forEach(function(t) {
            t.classList.remove('is-active');
        });
        if (!wasActive) {
            el.classList.add('is-active');
        }
    };

    // 풍선 외부 클릭 시 닫기
    document.addEventListener('click', function(e) {
        if (!e.target.closest('.help-balloon-trigger')) {
            document.querySelectorAll('.help-balloon-trigger.is-active').forEach(function(t) {
                t.classList.remove('is-active');
            });
        }
    });

    // Lightbox
    window.openLightbox = function(el) {
        var lb = document.getElementById('lightbox');
        var img = document.getElementById('lightbox-img');
        img.src = el.src;
        img.alt = el.alt;
        lb.classList.add('is-open');
        document.body.style.overflow = 'hidden';
    };

    window.closeLightbox = function() {
        var lb = document.getElementById('lightbox');
        lb.classList.remove('is-open');
        document.body.style.overflow = '';
    };

    document.addEventListener('keydown', function(e) {
        if (e.key === 'Escape') {
            closeLightbox();
        }
    });
})();
</script>
@endpush
