Container 與 VM 的架構與差別

Lee Wei
Jul 23, 2022

--

VM架構如下:

VM是使用Hypervisor去模擬硬體,達到分割作業系統的效果

container則是直接架在Linux Kernel上:

光從圖上就可以看出container輕量許多

VM有幾個明顯的問題:

  1. 一台VM通常會同時跑好幾個App,當你VM死掉時比較難查出是誰造成的
  2. VM的資源分配無法彈性調整,例如某台機器很閒你想把他的資源分給其他人,這在VM上比較難做到。
  3. 每一台VM裡面都要有OS,資源比較浪費

Container的基本原理是用Linux的指令來達到process的隔離

  1. cgroup: 資源限制
  2. namespace: pid、網路、掛載點

版本相依

以傳統VM開發來說,可能會遇到VM的執行環境與開發人員的環境不同,需要升版等問題。而container則是把相依的執行環境都打包進去image,維運端根本不需要考慮版本相依的問題。

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Lee Wei
Lee Wei

Written by Lee Wei

0 Followers

啊…就這樣吧。

No responses yet

Write a response