2021年7月2日 星期五

Ubuntu Install Docker Engine

支援 x86_64/amd64、armhf、和 arm64 架構。

Docker Engine 是一個 client-server 應用,包括

  • daemon server -- dockerd 和
  • CLI client -- docker,

透過 Docker REST API 溝通。

支援 overlay2、aufs、和 btrfs storage drivers。預設使用 overlay2,如果要用 aufs 需要手動設定。

安裝方式

  • 從 Docker’s repositories 安裝
  • 下載 DEB 檔手動安裝
  • 使用 script 安裝

會建立 docker 群組,但無使用者,需要 sudo 執行 docker 指令。

執行 hello-world image 驗證安裝成功。

sudo docker run hello-world

顯示下列訊息後結束

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete 
Digest: sha256:df5f5184104426b65967e016ff2ac0bfcd44ad7899ca3bbcf8e44e4461491a9e
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/

dockerd 以 root 身份執行,bind to 一個 Unix socket,需要 sudo 才能存取。加入 socker 群組的使用者可免除 sudo。Continue to Linux postinstall to allow non-privileged users to run Docker commands and for other optional configuration steps.

注意安全問題:執行 container 隱含執行 dockerd,只能開給信任的使用者。host 的目錄可共享給 container,例如 host 的 / 目錄,於是 container 可以沒有限制地更動。透過網路存取也要小心,需要加密或限制網域。

自動啟動 dockerd

設定檔:docker.service, containerd.service

參考

  1. https://docs.docker.com/engine/install/ubuntu/
  2. https://docs.docker.com/engine/install/linux-postinstall/
  • 非 root 執行 dockerd (rootless mode)
  • container 可視為應用程式一種標準包裝
  • REST API

沒有留言:

張貼留言

SIP header Via

所有 SIP 訊息 都要有 Via,縮寫 v。一開始的 UAC 和後續途經的每個 proxy 都會疊加一個 Via 放傳送的位址,依序作為回應的路徑。 格式 sent-protocol sent-by [ ;branch= branch ][ ; 參數 ...] s...