Debian12如何卸载Docker?

# 停止Docker运行
systemctl stop docker.socket
systemctl stop docker
 
# 卸载相关包
for i in $(dpkg -l | grep -i docker | awk '{print $2}'); do
  apt purge -y "$i"
  apt autoremove -y --purge "$i"
done

 
# 删除相关文件
rm -rf            \
  /etc/docker     \
  /var/lib/docker \
  /var/run/docker.sock

# 删除现有的docker用户组
groupdel docker

apt install -y net-tools bridge-utils

for i in $(brctl show | awk 'NR>1 {print $1}'); do
  ifconfig "$i" down  # 禁用docker网桥网络接口
  brctl delbr "$i"    # 删除现有的docker以太网桥
done

# 验证是否卸载
docker --version