unbuntu 安装docker docker-ce E: Sub-process /usr/bin/dpkg returned an error code (1)
时间: 2023-12-01 21:40:33 浏览: 120
Docker问题——安装过程中问题Errors were encountered while processing: docker-ce
5星 · 资源好评率100%
以下是安装docker-ce的步骤:
1.卸载旧版本的Docker
```bash
sudo apt-get remove docker docker-engine docker.io containerd runc
```
2.更新apt包索引并安装依赖包
```bash
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
```
3.添加Docker官方GPG密钥
```bash
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
```
4.设置Docker稳定版仓库
```bash
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
```
5.更新apt包索引并安装Docker CE
```bash
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
```
如果在安装过程中出现错误"E: Sub-process /usr/bin/dpkg returned an error code (1)",可以尝试以下解决方法:
1.运行以下命令以清除Docker安装的残留文件
```bash
sudo rm /var/lib/dpkg/info/docker-ce*
sudo dpkg --configure -a
sudo apt-get purge docker-ce
sudo apt-get autoremove
sudo apt-get autoclean
```
2.重新安装Docker CE
```bash
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
```
阅读全文