blog/_posts/Linux/docker/clear-docker.md
2024-05-12 14:14:45 +08:00

57 lines
1.1 KiB
Markdown
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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