Kai Chen
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 六角鼠年鐵人賽 Week 1 - 介紹 Docker ==大家好,我是 "為了拿到金角獎盃而努力著" 的文毅青年 - Kai== ## What is **Docker**? 在 **Docker** (或類似容器的技術) 出現以前,絕大多數的Server都是一台硬體切成許多不同大小單位的VM,有的放DB、有的放網站、有的放API等。 如果不同VM之間的差異很大,包含像是系統設定、安裝軟體的不同,那對於系統工程師來說使用VM作空間區隔是完全沒有問題的事情。 但如果今天許多VM之間的差異很小,例如微服務架構會開設很多環境給不同功能的API使用,這類VM的環境與設定其實非常相似,對於系統工程師來說卻要花許多時間調整各個 VM,這還不包含後續維護的部分。 **Container** (容器概念) 的出現正是解決了上述的問題,而用來管理這些容器的工具就是 **Docker**,因此要學 **Docker**,更應該懂容器到底幫助了我們什麼事情。 ## Why is **Docker**? 你可能遇到以下這些狀況: - 想個人創業,在資金燒完以前快速搭起自己的網站商城,開始進行交易賺錢 - 老闆交代必須在時限前搭起十個API服務,而這些服務要能夠隨時被部署到不同Server去運行。 遇到類似狀況時,架設一個VM、兩個VM,準備好開發環境、客戶環境,在一個專案期限內不停跟時間賽跑,且最終產品端的環境也無法保證移植後不會出錯。 **Docker** 建置 **Container** 的方式為在同一個環境建置不同的虛擬 Instance,這些 Instance 保有獨立的函式庫與Shell,且為 Linux 原生的關係,不受限虛擬技術的支援性差異,大大降低了建置難度與時間。 此外 **Docker** 建置 **Container** 後的映像檔,其內容包含了該環境的資源參數,可以讓任何其他 **Docker** 參照後從網路上下載需要的資源回到 Local 端安裝,免除了上述遇到的環境設定可能不同的問題,方便開發人員在不同的 **Docker** 內裝置相同的 **Container**。 比起 VM,使用 **Docker** 完全可以滿足快速開發的需求 ## **Docker** V.S. VM 我們先來看看實體機、VM和容器的架構: ==網路上有其他更好的圖片可以參考,以下畫個大概== ![](https://i.imgur.com/EQO6DQr.png) 眼尖的各位是否有看出來呢 (**還特別用顏色作區隔 e.m. 淺紫、深紫**)? 如上圖得比較,VM是在Server內切割出不同完整的空間,VM與VM之間完全區隔的狀況,資源互不共享,個體非常獨立。 **Docker** 則是透過命名空間的技術在同一個環境中進行應用程式劃分,讓不同 **Container** 的應用程式可以享受到同一個作業環境的資源與設定且同時又互相分離。 ## 安全性 ### VM 比 **Docker** 安全 由於 VM 是將Server空間處理成近乎完全獨立,因此在安全性方面比 **Docker** 高,被入侵、攻破都還可以當作獨立事件來看待。 **Docker** 則是因與主機共享相同的系統內核,一旦被入侵雖不會導致其他容器遭受攻擊,但應用相同的系統元件則會影響到其他容器應用程式,因此在使用 **Docker** 的時候,資安方面的考量會比 VM 要投入更多的資源。 當然以上不是說 VM 的資安只需要60分然後 **Docker** 需要90分這樣,比較是說如果VM做到了90分,那**Docker**可能需要做到95 99 甚至 100分的程度。 ## 資源 ### 將 10 個 VM 替換成 1000個 **Container**s 這算是一個玩笑,但也凸顯了 **Container** 的優勢,那就是少量的資源即可建立。 我們可以選擇在一台Server上,建置幾個VM,但也可以選擇利用 **Docker** 部屬更多的 **Container**s,搭載更多服務,使Server運營的效益最大化。 **Container** 不僅在讀取速度(秒單位)比VM快很多(分鐘單位),甚至連建立的虛擬硬碟容量都可以控制在MB單位 (VM為GB單位),大幅降低了資源需求。 正因如此,**Docker** 成了微服務架構的第一選擇,許多的 API Service 不再集中於同個作業環境中,對一個一個被切割出來的 API Service 來說,VM 顯得碩大且笨重。當可以用一個輕量化的容器去包裝這些服務時,何苦還勞心勞力開一個 VM? ## 可攜性 ### Wherever you want, you build. 是不是也有過在Linux可以Run,但是切到Windows卻Stop by error? 是不是有在開發環境明明沒問題,但到客戶端卻慘遭滑鐵盧的經驗? **Docker** 容器映像功能的支持,讓開發人員可以簡單地將開發環境打包,帶去客戶端直接展開部署完成。 只要確保雙方的作業環境都有建置 **Docker**,開發人員或部署人員在處理環境的時間與精力就會減少很多。 概念類似只要有JVM環境,就能執行JAVA程式;只要有Browser就能讀取HTML文件。 ## 未來性 **Docker** 因為建置耗費資源少、部屬快速、部屬環境廣泛等優點而迅速被許多資訊公司使用,取代傳統VM的處理,在未來快速發展的時代,幾乎是資訊人員的必備技能。 ## 結語 :::danger 下一篇將會分享 **安裝 Docker** 的學習心得 [六角鼠年鐵人賽 Week 2 - 安裝 Docker](/-8sBw1VMQ0ePfNFqjLmSIA) ::: 首頁 [Kai 個人技術 Hackmd](/2G-RoB0QTrKzkftH2uLueA) ###### tags: `Docker`,`w3HexSchool`

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    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

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    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.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully