# Docker-ce 安裝過程 ## 學校安裝 首先,先下載 Docker 的金鑰(這樣做的目的是為了確保下載的 Docker 軟體包是由 Docker 官方發布並經過驗證的)<pre>curl -fsSL `https://download.docker.com/linux/debian/gpg` | sudo apt-key add -</pre> --- 添加一個新的 APT 軟體庫來源,之後可以使用 APT 套件管理器來安裝 Docker 軟體包<pre>echo 'deb `https://download.docker.com/linux/debian` stretch stable' > /etc/apt/sources.list.d/docker.list</pre> --- 再來更新系統輸入`apt update -y`會發現跳出錯誤 :::warning W: https://download.docker.com/linux/debian/dists/stretch/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details. ::: 跳出這個錯誤代表原本新增的APT金鑰已經過期,所以要更新金鑰才有辦法繼續,這時先列出系統中所有已經加入到 APT 金鑰鏈的金鑰`apt-key list`找到今天要安裝的Docker  先複製後8個字`0EBF CD88`,再把key丟到GPG 公鑰的專用目錄`/etc/apt/trusted.gpg.d`,以替代使用 apt-key 直接加入到過時的 APT 金鑰鏈的方式 <pre>apt-key export 0EBFCD88 | gpg --dearmour -o /etc/apt/trusted.gpg.d/</pre> --- 更新系統就ok了`apt update -y`  --- 這時直接下`apt install docker-ce -y`就成功安裝好Docker-ce了! 現在是看一下`docker run hello-world`  發生錯誤時代表沒有開啟服務,所以下`service docker start`,在執行一次`docker run hello-world`會發現又出了錯誤 :::warning docker: Error response from daemon: cgroups: cgroup mountpoint does not exist: unknown. ::: 可能是因為系統中缺少必要的 cgroup 掛載點或者 Docker 守護程序無法正確訪問這些掛載點,這時手動新增掛載點 <pre>mkdir /sys/fs/cgroup/systemd mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd </pre> --- 這時在下一次`docker run hello-word`就正常了 `docker run hello-world`  `docker images`  `docker version`  ## 官方安裝 1. `apt update -y` 2. `apt-get install -y ca-certificates curl gnupg lsb-release` 3. `curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg` 4. `echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian bullseye stable` 5. `apt update -y` 6. `apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y` 7. `service docker start` **就完成了** ## 問題 ### Error: Sub-process /usr/bin/dpkg returned an error code (1)  - 代表dpkg出現問題,一般是安裝失敗後或被中斷時發生 - fix 1 - `sudo dpkg --configure -a` - 把已經解壓縮但還沒安裝的package進行重新配置,一般適用 - fix 2 - `sudo apt install -f` - 自動修復依賴性問題,發生網路問題導致安裝中斷可以用此 ## 參考 - [解決Key is stored in legacy trusted.gpg keyring](https://blog.clarence.tw/2023/05/28/%E5%9C%A8-ubuntu-%E5%87%BA%E7%8F%BE-key-is-stored-in-legacy-trusted-gpg-keyring-etc-apt-trusted-gpg-%E7%9A%84%E8%A7%A3%E6%B1%BA%E6%96%B9%E6%B3%95%E4%BB%A5-hashicrop-%E7%82%BA%E4%BE%8B/) - [cgroup mountpoint does not exist: unknown](https://www.php5.idv.tw/wordpress/?p=1143) - [[SOLVED]Cannot Install docker-ce on Debian Stretch](https://forums.docker.com/t/solved-cannot-install-docker-ce-on-debian-stretch/50407/6)
×
Sign in
Email
Password
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