Docker Certified Associate(DCA)認證考試學習-準備環境 Docker Certified Associate(DCA)認證相關資源、準備操作環境

Published on Friday, February 10, 2023

Docker Certified Associate

Docker Certified Associate(DCA),是目前Docker官方推廣的證照,接下來的幾篇文章會透過準備DCA來加強自身對Docker的操作與基礎知識

本次主要會透過dockerlabs提供的相關Lab來輔助學習

事前準備

在開始練習之前有兩點需要先確定:

  • 註冊Docker Hub帳號
  • 準備測試環境

註冊Docker Hub帳號這邊不再贅述了可以參考連結教學Create Docker Hub

測試環境可以選擇:

Play with Docker(PWD)會提供一個免費的Linux環境讓你測試docker的command,而且支援直接在瀏覽器中操作,但使用之前需要先有Docker Hub帳號
DCAPrepareGuide-PlayWithDockerStartPage

按下Start之後,網站會分配一個新的Session給你,總共有4小時的使用時間,超時後資料會被清除需要注意 DCAPrepareGuide-NewSession

左方按下Add New Instance之後,網站會分配一個測試環境給你,這邊可以添加多台Instance來測試服務跨機器連線等需求,為了避免浪費使用完畢時可以按下Delete按鈕提前將Instance刪除
DCAPrepareGuide-NewInstance

環境建立完之後就可以愉快玩耍了

Hello World

接下來我們繼續參考dockerlabs網站,在下方作者很貼心的根據不同人的需求設計了三種難度的Lab
我們這邊就從最初級的Docker for Beginner開始

有了目標之後,先測試看看環境是否正常,我們可以運行以下命令,此命令會運行一個測試用的容器然後回傳測試的內容

docker run hello-world

如果一切正常的話會輸出以下文字到畫面上
DCAPrepareGuide-HelloWorld

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:aa0cc8055b82dc2509bed2e19b275c8f463506616377219d9642221ab53cf9fe
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

從說明可以看出Docker有做了以下幾件事

  • Docker client 與 Docker daemon 建立連線
  • Docker daemon 尋找本地是否有叫做 hello-world 的Image
  • Docker daemon 找不到此Image轉而從Docker Hub 下載一個最新版的hello-world Image
  • Docker daemon 利用剛下載好的Image建立一個新的Container,運行Container程式準備輸出以上的內容
  • Docker daemon 將內容輸出給 Docker client最後顯示在我們的終端機上

Summary

今天我們根據dockerlabs的教學建立了我們自己的Docker hub帳號,並且利用Play with Docker(PWD)測試環境,運行了我們第一個容器hello-world。

接下來我會根據以上列出的五點依序了解,從底層認識Docker同時也認識更多平常比較少用的命令。