or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
不賴陪你玩 Docker
docker 自架服務不求人
https://hackmd.io/@fly/docker101
嘿!兩兩分組認識一下如何? (15 mins)
出場人物
伴學目標
不賴的 Docker 經驗
Why Docker
https://ithelp.ithome.com.tw/articles/10190614
一些好處
https://ithelp.ithome.com.tw/articles/10237506
嘿!安裝 Docker 來相陪 (30 mins)
安裝 Docker
https://docs.docker.com/desktop/
https://ithelp.ithome.com.tw/articles/10238198
https://ithelp.ithome.com.tw/articles/10201630
虛擬機安裝 https://ithelp.ithome.com.tw/articles/10193928MAC
裝完即用
WINDOWS
可能會碰到的坑
- 可使用虛擬機安裝(過時)有時候因為某些理由,可能會不想或無法(如 Windows 7)在原生系統上安裝 Docker,這時可以考慮使用虛擬機安裝。
https://ithelp.ithome.com.tw/articles/10238198
LINUX (todo)
注意:必須要是 64-bit 版本才能運行 Docker。
嘿!三三兩兩來研究想一鍵啟動服務吧
一行指令快速啟動你要的服務
https://github.com/relink2013/Awesome-Self-hosting-for-the-whole-family
一些 Image 範例
技術原理(如果有興趣了解再看下去)
嘿!Docker
Docker 包括三個基本概念 :
映像檔(Image)唯讀映像檔,可堆疊的貨櫃
容器(Container) image 執行起來的 process,船運行程
倉庫(Repository)存放處,港口倉庫
另一個與 repository 很像,但容易混用的名詞為 Registry,後者涵蓋範圍更廣,包含了更多 repository 與身分驗證功能等,通常比較常討論的也是 registry。
目前 Docker 預設的 registry 為 DockerHub,大多數程式或服務的 image 都能在上面找得到。
https://hub.docker.com ,港口
Image、container、repository 之間的關係就像光碟一樣:早期世紀帝國等光碟遊戲,會需要搭配其他可讀寫空間(如硬碟),才有辦法執行。
Image 像光碟片一樣,唯讀且不能獨立執行
Container 像硬碟一樣,可讀可寫可執行
Repository 則是光碟盒,而 Registry 則是像光碟零售商
https://ithelp.ithome.com.tw/articles/10238216
https://ithelp.ithome.com.tw/articles/10238216
玩映像檔 Image
玩容器 Container
https://ithelp.ithome.com.tw/articles/10190921
-i|–interactive 和 -t|–tty
docker exec VS docker run
docker run 與 docker exec 做的事很相似,決定性差異在於:docker run 會產生新的 container,而 docker exec 需要運行中的 container。
玩 registry
docker run -d -p 5000:5000 -v /home/user1/storage:/var/lib/registry --name registry registry:2
Image 匯出與讀取
Docker Volume 處理資料
在預設的Docker daemon下,我們常會遇到幾種情況:
在使用 docker run 指令時,指定 -v 參數,使得實體主機的資料夾路徑 Mapping 到 Container 的資料夾路徑,指令如下
/home/user1/storage 是實體主機的資料夾路徑 Mapping 到 Container 裡面的 /storage 資料夾路徑。
https://ithelp.ithome.com.tw/articles/10192397
https://ithelp.ithome.com.tw/articles/10241922
network
Container是個封閉的空間,但難免有些功能開發是需要與其他Containers甚至是外界串接的,因此Docker network因應不同需求發展出了多種類別的network
https://ithelp.ithome.com.tw/articles/10242460
docker-compose 處理多個 Container
想要彈性地處理更多子服務,可以了解 Docker-compose
參見
https://g0v.hackmd.io/65RtkztoTDuDVreqtFHxtQ#主要結構說明
https://ithelp.ithome.com.tw/articles/10194183
https://ithelp.ithome.com.tw/articles/10243618
查看 Docker Container 的資源使用狀態
-c / —cpus
原本預設值為1024, 一半即為512,是相對值,佔用主機一半cpu資源
https://ithelp.ithome.com.tw/articles/10243101
Container 應用
https://ithelp.ithome.com.tw/articles/10242637
Docker build / Dockerfile to Image
https://ithelp.ithome.com.tw/articles/10244280
using cache
https://ithelp.ithome.com.tw/articles/10246065
https://ithelp.ithome.com.tw/articles/10240510
可能的坑
非伺服器也能對外開放服務,反向代理
反向代理讓你的桌機自架服務可以快速對外開放
Ngrok
More…
localtunnel
https://github.com/localtunnel/localtunnel
One more thing
參考
https://g0v.hackmd.io/@MRLyM3ynSfmNj1QrR_csrQ/SJx85m828
https://hackmd.io/v1jFG5KhTnKX5gGKjtf8lg
https://www.osboxes.org/virtualbox-images/
為各種框架 build image https://ithelp.ithome.com.tw/articles/10247679
好吧,你說你只是想要簡單架服務?
連 Docker 都不用學,直接在 VPS 上快速啟用想要的服務(我是不是太晚講? XD)
https://www.youtube.com/watch?v=D1soV_Ff7uk