2021-09-29

Docker Remove Compeletely

#!/bin/bash
#/opt/script/docker-remove-compeletely.sh
#LastUpdate: #15:13 2021.09.29
#############################################
echo "#############################################"
echo "STOP ALL RUNNING CONTAINER:"
echo "docker container stop $(docker container ls -aq)"
sleep 5
docker container stop $(docker container ls -aq)


echo "#############################################"
echo "DELETE ALL CONTAINER:"
echo "docker container rm $(docker container ls -aq)"
sleep 5
docker container rm $(docker container ls -aq)

echo "#############################################"
echo "DELETE ALL IMAGES:"
echo "docker image prune -a"
sleep 5
docker image prune -a


echo "#############################################"
echo "DELETE ALL DOCKER DATA ON SERVER:"
sleep 5

dpkg -l | grep -i docker
sudo apt-get purge -y docker-engine docker docker.io docker-ce docker-ce-cli
sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce

sudo apt-get purge -y docker-ce docker-ce-cli containerd.io
sudo apt-get remove docker docker-engine docker.io containerd runc

sudo \rm -rf /var/lib/docker
sudo \rm -rf /var/lib/containerd

find / -name "*docker*" -exec \rm -rf {} \;


echo "#############################################"
echo "DELETE DOCKER NETWORK INTERFACE:"
echo "ip link delete docker0"
sleep 5
ip link delete docker0


echo "#############################################"
echo "CHECKING EXISTED DOCKER on SERVER:"
echo "find / -name docker"
echo "find / -name docker.io"
sleep 5


#THE_END

#REF:
##https://askubuntu.com/questions/935569/how-to-completely-uninstall-docker

No comments:

Post a Comment