2022-10-12 01:32:19 +00:00
|
|
|
|
---
|
2023-11-10 09:47:10 +00:00
|
|
|
|
title: 🧩完全清除docker
|
2022-10-12 01:32:19 +00:00
|
|
|
|
date: 2022-10-07
|
2023-11-10 09:47:10 +00:00
|
|
|
|
tags:
|
|
|
|
|
- Docker
|
|
|
|
|
- Ubuntu
|
2022-10-12 01:32:19 +00:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
目前开发的笔记本使用的是ubuntu22.04.1 桌面版本,docker-desktop 正好有桌面版本,所以安装桌面版本比较合适。这边小记一下如何清除已有老旧docker,**注意这里是完全清除老旧docker,原来的image和容器都会被清理!**
|
|
|
|
|
|
2023-11-10 09:47:10 +00:00
|
|
|
|
## 步骤如下
|
2022-10-12 01:32:19 +00:00
|
|
|
|
|
2023-11-10 09:47:10 +00:00
|
|
|
|
1.删除某软件及其安装时自动安装的所有包
|
2022-10-12 01:32:19 +00:00
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
sudo apt-get autoremove docker docker-ce docker-engine docker.io containerd runc
|
|
|
|
|
```
|
2023-11-10 09:47:10 +00:00
|
|
|
|
|
|
|
|
|
2.删除无用的相关的配置文件
|
|
|
|
|
|
2022-10-12 01:32:19 +00:00
|
|
|
|
```sh
|
|
|
|
|
dpkg -l | grep docker
|
|
|
|
|
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
|
|
|
|
|
```
|
2023-10-24 02:54:34 +00:00
|
|
|
|
<!--more-->
|
2023-11-10 09:47:10 +00:00
|
|
|
|
3.卸载没有删除的docker相关插件,比如
|
|
|
|
|
|
|
|
|
|
```sh
|
2022-10-12 01:32:19 +00:00
|
|
|
|
sudo apt-get autoremove docker-ce-*
|
|
|
|
|
```
|
|
|
|
|
|
2023-11-10 09:47:10 +00:00
|
|
|
|
4.删除docker的相关配置,命令如:
|
|
|
|
|
|
2022-10-12 01:32:19 +00:00
|
|
|
|
```sh
|
|
|
|
|
sudo rm -rf /etc/systemd/system/docker.service.d
|
|
|
|
|
sudo rm -rf /var/lib/docker
|
|
|
|
|
```
|
|
|
|
|
|
2023-11-10 09:47:10 +00:00
|
|
|
|
5.最后再查询下docker相关软件包
|
|
|
|
|
|
|
|
|
|
```sh
|
2022-10-12 01:32:19 +00:00
|
|
|
|
dpkg -l | grep docker
|
|
|
|
|
```
|
|
|
|
|
|
2023-11-10 09:47:10 +00:00
|
|
|
|
6.如果还有包存在,则删除,可能会有多个
|
|
|
|
|
|
|
|
|
|
```sh
|
2022-10-12 01:32:19 +00:00
|
|
|
|
sudo apt remove --purge xxx#
|
2023-11-10 09:49:55 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 验证
|
|
|
|
|
|
|
|
|
|
```sh
|
2022-10-12 01:32:19 +00:00
|
|
|
|
# 验证下 此处应该报错
|
|
|
|
|
docker -v
|
|
|
|
|
```
|