{
 "為什麼資料會消失?三種儲存方式#1": {
  "type": "cards",
  "reveal": [
   0,
   1,
   2,
   3,
   4,
   4
  ],
  "cards": [
   {
    "title": "刪容器資料就沒了",
    "points": [
     "docker rm 會",
     "restart 不會"
    ]
   },
   {
    "title": "可寫層效能較差",
    "points": [
     "儲存驅動寫入時複製"
    ]
   },
   {
    "title": "資料難共用",
    "points": [
     "別的容器讀不到"
    ]
   },
   {
    "title": "升級困難",
    "points": [
     "換新版要刪舊容器"
    ]
   }
  ]
 },
 "為什麼資料會消失?三種儲存方式#2": {
  "type": "cards",
  "reveal": [
   0,
   1,
   2,
   3
  ],
  "cards": [
   {
    "title": "volume",
    "points": [
     "Docker 管理",
     "用名字引用"
    ]
   },
   {
    "title": "bind mount",
    "points": [
     "主機指定的目錄或檔案",
     "路徑自己決定"
    ]
   },
   {
    "title": "tmpfs",
    "points": [
     "放在主機記憶體",
     "容器停止即消失"
    ]
   }
  ]
 },
 "為什麼資料會消失?三種儲存方式#3": {
  "type": "table",
  "reveal": [
   0,
   0,
   1,
   2,
   3
  ],
  "head": [
   "項目",
   "volume",
   "bind mount",
   "tmpfs"
  ],
  "rows": [
   [
    "誰管理",
    "Docker 管",
    "自己管",
    "記憶體"
   ],
   [
    "典型用途",
    "資料庫、長期保存",
    "開發同步、掛設定檔",
    "暫存、機密暫存"
   ],
   [
    "備份遷移",
    "docker 指令容易",
    "直接操作主機檔案",
    "不保存"
   ]
  ],
  "widths": [
   2,
   3,
   3,
   3
  ]
 },
 "為什麼資料會消失?三種儲存方式#4": {
  "type": "table",
  "reveal": [
   0,
   1,
   2
  ],
  "head": [
   "項目",
   "volume",
   "bind mount"
  ],
  "rows": [
   [
    "主機路徑依賴",
    "無",
    "有,路徑須存在"
   ],
   [
    "權限問題",
    "較少",
    "容易遇到"
   ]
  ],
  "widths": [
   3,
   3,
   3
  ]
 },
 "為什麼資料會消失?三種儲存方式#5": {
  "type": "table",
  "reveal": [
   0,
   1,
   2,
   3,
   4
  ],
  "head": [
   "情境",
   "選擇"
  ],
  "rows": [
   [
    "資料庫、上傳檔、長期保存",
    "volume"
   ],
   [
    "開發時即時同步",
    "bind mount"
   ],
   [
    "唯讀設定檔",
    "bind mount + ro"
   ],
   [
    "不想寫入磁碟的暫存",
    "tmpfs"
   ]
  ],
  "widths": [
   4,
   3
  ]
 },
 "Volume 操作:資料庫持久化實例#2": {
  "type": "table",
  "reveal": [
   0,
   1,
   2,
   2,
   2,
   3
  ],
  "head": [
   "指令",
   "用途"
  ],
  "rows": [
   [
    "volume create dbdata",
    "建立 volume"
   ],
   [
    "volume ls",
    "列出,驅動為 local"
   ],
   [
    "volume inspect dbdata",
    "詳細資訊與掛載點"
   ]
  ],
  "widths": [
   4,
   3
  ]
 },
 "Volume 操作:資料庫持久化實例#4": {
  "type": "cards",
  "reveal": [
   0,
   1,
   2,
   3
  ],
  "cards": [
   {
    "title": "-e 密碼",
    "points": [
     "設定 root 密碼",
     "畫面為占位符,自行產生強密碼"
    ]
   },
   {
    "title": "-e 資料庫",
    "points": [
     "建立 appdb"
    ]
   },
   {
    "title": "-v dbdata",
    "points": [
     "掛到資料庫資料目錄",
     "資料能否留下的關鍵"
    ]
   }
  ]
 },
 "Volume 操作:資料庫持久化實例#7": {
  "type": "flow",
  "reveal": [
   0,
   2,
   3,
   4,
   4
  ],
  "nodes": [
   {
    "label": "寫入 notes",
    "sub": "資料表與一筆資料",
    "color": 0
   },
   {
    "label": "docker rm -f db",
    "sub": "刪掉容器",
    "color": 1
   },
   {
    "label": "新容器",
    "sub": "接同一 volume",
    "color": 2
   },
   {
    "label": "資料還在",
    "sub": "與容器脫鉤",
    "color": 3,
    "kind": "end"
   }
  ]
 },
 "Bind Mount、tmpfs 與權限問題#1": {
  "type": "cards",
  "reveal": [
   0,
   0,
   1,
   2,
   3,
   4
  ],
  "cards": [
   {
    "title": "絕對路徑",
    "points": [
     "用 $HOME 或 $(pwd)"
    ]
   },
   {
    "title": ":ro 唯讀",
    "points": [
     "設定檔、靜態網站都加"
    ]
   },
   {
    "title": "路徑有空白",
    "points": [
     "加上引號"
    ]
   },
   {
    "title": "--mount 寫法",
    "points": [
     "type=bind、source、target",
     "最後加 readonly"
    ]
   }
  ]
 },
 "Bind Mount、tmpfs 與權限問題#2": {
  "type": "flow",
  "reveal": [
   0,
   1,
   2,
   3
  ],
  "nodes": [
   {
    "label": "mkdir ~/site",
    "sub": "建立資料夾",
    "color": 0
   },
   {
    "label": "寫入首頁",
    "sub": "Bind mount works",
    "color": 1
   },
   {
    "label": "docker run",
    "sub": "-p 8080:80 加 :ro",
    "color": 2,
    "kind": "end"
   }
  ]
 },
 "Bind Mount、tmpfs 與權限問題#5": {
  "type": "table",
  "reveal": [
   0,
   1,
   2,
   2
  ],
  "head": [
   "狀況",
   "結果"
  ],
  "rows": [
   [
    "容器用 1000,主機目錄屬 root",
    "Permission denied"
   ],
   [
    "容器用 root 寫入",
    "主機出現 root 檔案"
   ]
  ],
  "widths": [
   4,
   3
  ]
 },
 "Bind Mount、tmpfs 與權限問題#6": {
  "type": "cards",
  "reveal": [
   1,
   2,
   3,
   4,
   4
  ],
  "cards": [
   {
    "title": "-u UID:GID",
    "points": [
     "用和主機相符的使用者"
    ]
   },
   {
    "title": "sudo chown",
    "points": [
     "改主機目錄擁有者",
     "執行前確認路徑"
    ]
   },
   {
    "title": "具名 volume",
    "points": [
     "交給 Docker 管理"
    ]
   },
   {
    "title": "不要開 777",
    "points": [
     "等於把大門打開"
    ]
   }
  ]
 },
 "Bind Mount、tmpfs 與權限問題#7": {
  "type": "cards",
  "reveal": [
   0,
   1,
   2,
   3
  ],
  "cards": [
   {
    "title": "不掛的目錄",
    "points": [
     "根目錄、系統設定",
     "root 家目錄、整個家目錄"
    ]
   },
   {
    "title": "docker.sock",
    "points": [
     "掛進容器等於控制整台主機"
    ]
   },
   {
    "title": "機密路徑",
    "points": [
     "如 SSH 金鑰目錄",
     "掛之前再三確認"
    ]
   }
  ]
 }
}