方案1:使用Ubuntu官方仓库的Docker(最简单)
sudo apt update
sudo apt install -y docker.io docker-compose
sudo systemctl start docker
sudo systemctl enable docker
Ubuntu官方仓库中有Docker包,虽然版本可能不是最新的,但足够使用:
验证安装:
docker --version
sudo docker run hello-world
方案2:使用阿里云镜像源安装Docker CE
如果需要最新版本的Docker,可以使用国内镜像源:
卸载旧版本(如果有)
sudo apt remove docker docker-engine docker.io containerd runc
安装依赖
sudo apt update
sudo apt install -y ca-certificates curl gnupg lsb-release
添加阿里云Docker GPG密钥
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
添加阿里云Docker仓库
echo “deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable” | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
更新并安装Docker
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
启动Docker
sudo systemctl start docker
sudo systemctl enable docker
方案3:使用清华大学镜像源
添加清华大学Docker GPG密钥
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
添加清华大学Docker仓库
echo “deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable” | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
更新并安装
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl start docker
sudo systemctl enable docker
推荐:先试方案1
我建议您先使用方案1(Ubuntu官方仓库),这是最简单且不需要访问外网的方法:sudo apt update && sudo apt install -y docker.io docker-compose && sudo systemctl start docker && sudo systemctl enable docker
安装成功后验证:
docker --version
sudo docker ps

9753

被折叠的 条评论
为什么被折叠?



