Last active
August 10, 2023 06:45
-
-
Save BaksiLi/f86f760baae2ed4a6459624b8bbda4c2 to your computer and use it in GitHub Desktop.
Docker command to kill and remove a container with its image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias undock='f() { | |
if sudo docker kill $1; then | |
echo "[+] Successfully killed: $1" | |
else | |
echo "[-] Failed to kill: $1" | |
fi | |
if sudo docker rm $1; then | |
echo "[+] Successfully removed: $1" | |
else | |
echo "[-] Failed to remove: $1" | |
fi | |
unset -f f | |
}; f' | |
# One-line version | |
# alias undock='f() { sudo docker kill $1 && echo "[+] Successfully killed: $1" || echo "[-] Failed to kill: $1"; sudo docker rm $1 && echo "[+] Successfully removed: $1" || echo "[-] Failed to remove: $1"; unset -f f; }; f' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment