{%hackmd SybccZ6XD %} <style> .toc > ul > li:first-child { list-style: none; } .toc > ul > li:first-child > a { display: none; } </style> Docker === ###### tags: `essay` `Container` > [name=Shueh Chou Lu][time=Dec 25, 2020] [TOC] --- ## Why Container/VM? - shared libraries version conflict - shared filesystem or data → security issue ## VM vs Container - VM: `Virtual hardware` → `OS/kernel` → `Libs, FS` → APP _Host_ OS vs _Guest_ OS - Container: `Libs, FS` → APP ## Container ```mermaid graph TD subgraph Host OS Filesystem end subgraph Container 0[Image] Volume --> Filesystem Filesystem --> Volume Port end 1[Docker] --> 0 0 --> 1 2[Daemon] -- HTTP --> 1 3[Docker CLI] --> 2 4[Docker Hub] --> 2 2 --> 4 ``` ### Image 可以擴充 例如: `APP` extends `Node.js` which based on `Linux` - `Linux` 提供 _filesystem_ 和常見的 _libraries_ - `Node.js` 提供 _npm_ 和 _node_ ### Docker Desktop provide VM on develop environment. 線上環境中通常使用 `Linux`,但開發環境卻不是(macOS 或 window)。 透過 Docker Desktop 建立 VM 去支持 `Linux` 的功能。 除此之外,也可在建立 image 時去擴充`Linux`. Desktop 同時也提供 _admin UI_ 和 _Kubernetes_。 ### Dockerfile 用來說明 Docker Image 的陳述式檔案。 - 每一行代表一個 layer,每一個 `FROM` 代表一個 stage。 - 每個 layer 會有一個 hash 去確認修改,每次建立都會增加記憶體量,進而增加啟動時間。 - 每一個 stage 可以去修改指定的 filesystem 位置。 - 用 `docker history ${image}` 去查看每一個 layer 的歷程。 - 理論上,base image 檔案越小(`Alpine` v.s. `Debian`),該 image 受污染的範圍可能越小,安全性可能越高。
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up