Ubuntu安裝
??更新軟件包列表??
首先確保軟件包列表是最新的:
sudo apt-get update
?使用正確的卸載命令??
替換 docker-engine
為 docker-ce
或 docker.io
:
sudo apt-get remove docker docker-ce docker.io containerd runc
??檢查已安裝的 Docker 包??
如果仍提示找不到包,可能是系統未安裝 Docker。可通過以下命令確認:
- 卸載老的版本
$ sudo apt-get remove docker docker-engine docker.io containerd runc
- 更新apt包索引
$ sudo apt-get update
- 安裝必要工具包
$ sudo apt-get install \apt-transport-https \ca-certificates \curl \gnupg-agent \software-properties-common
- 添加Docker GPG秘鑰
# 1. 默認使用國外源,非常非常非常慢!
$ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# 2. 推薦使用國內源,順暢!
$ sudo curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
- 配置倉庫源
# 1. 默認使用國外源,非常非常非常慢!
$ sudo add-apt-repository \"deb [arch=amd64] https://download.docker.com/linux/ubuntu \$(lsb_release -cs) \stable"
# 2. 推薦使用國內源,順暢!
$ sudo add-apt-repository \"deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \$(lsb_release -cs) \stable"
- 安裝Docker Engine
# 更新apt包索引
$ sudo apt-get update# 安裝docker
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
- 啟動Docker
sudo systemctl enable docker
sudo systemctl start docker
2.3 驗證安裝是否成功
- 永遠的hello-world!
在docker啟動的前提下,在命令行輸入以下指令:
docker run hello-world