個人博客地址:Deepin 23.10安裝Docker | 一張假鈔的真實世界
Deepin 是基于 Debian 的國產 Linux 發行版,安裝 Docker Desktop 可能會遇到兼容性問題,因為 Docker Desktop 官方主要支持 Ubuntu/Debian/Red Hat/Fedora/Arch 等主流發行版,所以選擇安裝 Docker Engine。
- 卸載舊版本(如有)
sudo apt remove docker.io docker-doc docker-compose podman-docker containerd runc
- 安裝依賴
sudo apt update
sudo apt install -y ca-certificates curl gnupg lsb-release
- 添加 Docker 官方 GPG 密鑰
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
- 添加 Docker 源
由于 Deepin 基于 Debian,可以使用 Debian 的 Docker 源(需匹配 Deepin 版本對應的 Debian 版本)。
查看Deepin對應的Debian版本:
$ cat /etc/debian_version
bookworm/sid
執行以下命令添加 Docker 源:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian bookworm stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- 安裝 Docker Engine
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
- 啟動 Docker
sudo systemctl enable --now docker
- 允許普通用戶運行 Docker
sudo usermod -aG docker $USER
newgrp docker # 重新加載用戶組
可能需要重啟電腦。
- 測試 Docker
sudo docker run hello-world
需先配置國內鏡像源。現在可用的鏡像源越來越少了,推薦一篇良心博文:https://zhuanlan.zhihu.com/p/24461370776。
安裝成功的驗證結果信息如下:
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
e6590344b1a5: Pull complete
Digest: sha256:dd01f97f252193ae3210da231b1dca0cffab4aadb3566692d6730bf93f123a48
Status: Downloaded newer image for hello-world:latestHello 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 theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare 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/
Deepin 20.9 社區版安裝 Docker 見文章:Deepin 20.9 社區版安裝 Docker。
DockerHub 鏡像源配置見文章:Linux 配置 DockerHub 鏡像源配置。
Docker Compose 安裝見文章:Linux 系統 Docker Compose 安裝。